fastcgi-cache and expires

Reinis Rozitis r at
Sat Mar 30 10:59:04 UTC 2013

> Before I change it, is there any huge reason "fastcgi_ignore_headers 
> Cache-Control Expires;" and "expires epoch;" should stay in my 
> fastcgi-params file?

nginx honours the headers the backend sends.

Often dynamic applications (like php when using sessions etc) send headers 
which "deny" any kind of caching ( Cache-Control: no-store, no-cache, 
must-revalidate, post-check=0, pre-check=0 and Expires header in the past) 
so to cache such responses nginx has to override theese headers.

In this case though without the context the 'epires epoch;' directive makes 
not a lot of sense (at least for me) since it sets the epire header to 1 
January, 1970 00:00:01 GMT meaning it shouldn't be cached.

I always feel that setting the expire/cache headers in the application 
(unless imposible to change the code) is more flexible and allows to avoid 
errors (caching something for too long or wrong response) rather than 
overriding it in the proxy.

Also I wouldn't put the expire/header directives in the fastcgi_params file 
since that means you use those for every request versus putting in some 
specific location {} blocks.


More information about the nginx mailing list