In our checklist for perfect WordPress-Nginx setup, we have a section dedicated to check if page-caching will work in case PHP/MySQL backend crash. Some readers did not like my way of actually shutting down PHP backend for cache-verification.
If you are using Nginx’s
fastcgi_cache, then you can use
upstream_cache_status variable to test cache for particular URLs without shutting down PHP.
All you need to do is, add a line like below to
/etc/nginx/nginx.conf file, in
add_header rt-Fastcgi-Cache $upstream_cache_status;
Just reload nginx config:
service nginx reload
Check HTTP response for any page and you will see something like:
HTTP/1.1 200 OK Server: nginx Date: Fri, 26 Jul 2013 15:38:51 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Vary: Accept-Encoding X-Powered-By: PHP/5.4.17-1~precise+1 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Pingback: https://rtcamp.com/xmlrpc.php rt-Fastcgi-Cache: HIT
Please note last line. Value next to rt-Fastcgi-Cache indicates fastcgi-cache status.
If you see a MISS, send similar request again and it should get you a HIT.
If you see BYPASS, that means some conditions for skipping cache are met.