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".
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).
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).
Comments
[url=http://www.elysetiawan.com/]mas ely[/url]
[url]http://www.elysetiawan.com/[/url]
[http://www.elysetiawan.com/ kata kunci]
[blog peternakan ely->http://www.elysetiawan.com/]
http://www.elysetiawan.com/”>kata kunci
[peternakan ely|http://www.elysetiawan.com/]
[mahasiswa peternakan ely](http://www.elysetiawan.com/)
“blog peternakan”:http://www.elysetiawan.com/
mahasiswa peternakan (http://www.elysetiawan.com/)
(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