Fastcgi-cache and expires

Just curious…

In a lot of examples I’ve seen on the net for setting up fastcgi-cache
the
directives

fastcgi_ignore_headers Cache-Control Expires;
expires epoch;

are included. Is there any major reason for that? For my own setup I
want
the fastcgi caching to reduce load on the server, but I’d also like to
perhaps fine tune the browser caching with expires headers for some
pages.

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?

Thanks.

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.

rr

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs