How to fix: Nginx proxy or fastcgi cache always MISS or EXPIRED

I've recently had an issue with my Nginx setup: it wasn't caching or serving cached pages properly. Every time I would visit, I'd get "MISS" or "EXPIRED".

What I found online is that you have to instruct Nginx to ignore browser request headers relative to caching, therefore allowing Nginx to determine whether it should serve cache, all by itself.

This is done by inserting the following directive:

# ignore headers to let Nginx control its own cache
fastcgi_ignore_headers Cache-Control Expires;

However, I already had this in my configuration and it wasn't helping.

After investigating the issue, I determined that my PHP scripts were updating cookies at every request. Nginx was forced to execute the PHP scripts via FastCGI (ie. not serving them from cache) because the cookie data had changed. When PHP sets a cookie, Nginx will not hit the cache, which is normal behavior. I wouldn't recommend changing this behavior. What I did is fix my PHP scripts so that they wouldn't update cookies at every request. Once I did that, I started hitting the cache again!

One last thing: if you turn off fastcgi or proxy buffering, caching may not work properly, so make sure buffering is on (it should be on by default).


Ely setiawan said…
sangat bermanfaat kunjungi”>blog mas ely

[url=]mas ely[/url]


[ kata kunci]

[blog peternakan ely->]”>kata kunci

[peternakan ely|]

[mahasiswa peternakan ely](

“blog peternakan”:

mahasiswa peternakan (
Blogger said…
According to Stanford Medical, It's really the ONLY reason this country's women live 10 years more and weigh 42 lbs less than us.

(And by the way, it has totally NOTHING to do with genetics or some secret-exercise and EVERYTHING to do with "how" they eat.)

P.S, I said "HOW", and not "what"...

Click this link to reveal if this brief questionnaire can help you find out your true weight loss possibilities
Vevenia said…
Thanks for the help..

Popular posts from this blog

How to set up a simple mail server on Debian in 5 easy steps

Top 3 fixes for: Internet Explorer won't start, IE7, IE8, IE9 opens then closes immediately

JWPlayer: remembering position in video, to resume playback later