Forum: NGINX proxy_cache_valid question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Resicow (Guest)
on 2009-04-23 21:38
(Received via mailing list)
Hello Community,

Is it possible to assign different proxy_cache_valid values for
different file extensions? So for example .jpg could live in the cache
for 7 days, but .js files would only live for 6 hours?

I guess you could do this with multiple location directives, just don't
know exactly how or if it is supported.

Thanks,

John
Igor S. (Guest)
on 2009-04-23 23:28
(Received via mailing list)
On Thu, Apr 23, 2009 at 12:27:46PM -0500, Resicow wrote:

> Hello Community,
>
> Is it possible to assign different proxy_cache_valid values for
> different file extensions? So for example .jpg could live in the cache
> for 7 days, but .js files would only live for 6 hours?
>
> I guess you could do this with multiple location directives, just don't
> know exactly how or if it is supported.

    location ~ \.jpg$ {
        proxy_pass         ...;
        proxy_cache        ...;
        proxy_cache_valid  200 7d;
    }

    location ~ \.js$ {
        proxy_pass         ...;
        proxy_cache        ...;
        proxy_cache_valid  200 6h;
    }
Resicow (Guest)
on 2009-04-24 22:17
(Received via mailing list)
Thanks Igor,

Just want to confirm that the proxy_cache zone can be the same, so we
can set different proxy_cache_valid 200 values for keys in the same
proxy_cache zone?

Thanks

John
Igor S. (Guest)
on 2009-04-24 23:21
(Received via mailing list)
On Fri, Apr 24, 2009 at 01:06:20PM -0500, Resicow wrote:

> Thanks Igor,
>
> Just want to confirm that the proxy_cache zone can be the same, so we
> can set different proxy_cache_valid 200 values for keys in the same
> proxy_cache zone?

Yes, proxy_cache zone can be the same.
This topic is locked and can not be replied to.