proxy_store help requested

Maxim Dounin mdounin at
Wed Mar 12 11:48:23 UTC 2014


On Tue, Mar 11, 2014 at 12:46:18PM -0400, nginx_newbie_too wrote:

> Maxim, one last piece of advice requested. Would it be more proper to turn
> off i-m-s in the request body (by setting proxy_pass_request_headers to off
> in the downstream server configuration) instead of turning it off on the
> upstream server?  I think that's more correct behavior, but I'm not sure.

Something like

    proxy_set_header If-Modified-Since "";
    proxy_set_header If-None-Match "";

on a frontend should be a good way to disable If-* in requests to 
an upstream server.  I would recommend to don't touch it at all 
though, and just ignore 304 responses which are not stored.  
Number of 304 returned by upstream should be small enough.

> Yes, proxy_cache simply works out of the box, and it's awesome. But I
> couldn't understand how to use it so that the downstream server doesn't
> naively GET content again from the upstream after the expiration time period
> had passed. I would have wanted instead to only have the cache refreshed if
> i-m-s suggested that the upstream content had changed.

To make proxy_cache behave more like proxy_store and ignore 
response expiration, use proxy_ignore_headers (and 
proxy_cache_valid to set cache time):

    proxy_ignore_headers Cache-Control Expires;
    proxy_cache_valid 200 365d;

Use of If-Modified-Since to revalidate cached data can be 
activated by proxy_cache_revalidate directive.

See here for documentation:

Maxim Dounin

More information about the nginx mailing list