Cache always misses

I’ve followed the tutorial here and added an X-Cache header to see the status. When I test the cache with a simple script that outputs the timestamp (suggested here), caching works properly. The time stamp never updates, and the X-Cache header shows MISS/HIT/HIT, etc. However, any page I load on my blog never hits, it just MISSes every time I reload.

I’m hosting the blog in a subdirectory and have tried to compensate for that in the config, but maybe I made an error?

http {  
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;  
fastcgi_cache_key "$scheme$request_method$host$request_uri";  
fastcgi_cache_use_stale error timeout invalid_header http_500;  
add_header X-Cache $upstream_cache_status;  

index index.html index.php index.htm;  

  server {  
    access_log /var/www/;  
    error_log /var/www/;  

    root /var/www/;  
    set $skip_cache 0;  

    location /blog {  
         try_files $uri $uri/  /blog/index.php?q=$uri&$args;  
          if ($request_method = POST) {  
               set $skip_cache 1;  
          if ($query_string != "") {  
              set $skip_cache 1;  
        # Don't cache uris containing the following segments                                                                                                                                                                                                                                 
        if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml")                
           set $skip_cache 1;  
        # Don't use the cache for logged in users or recent commenters                                                                                                                                                                                                                       
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {  
           set $skip_cache 1;  

	location ~ \.php$ {  
                try_files $uri =404;  
                fastcgi_pass unix:/var/run/php5-fpm.sock;  
                include fastcgi_params;  
		fastcgi_cache_bypass $skip_cache;  
                fastcgi_no_cache $skip_cache;  
                fastcgi_cache WORDPRESS;  
                fastcgi_cache_valid  60m;  
                fastcgi_split_path_info ^(.+\.php)(/.+)$;  

Also, when I look at the source, the plugin reports caching properly (Cached using Nginx-Helper…), but the time stamp changes every time I reload the page.

It looks like you have mixed many configs.

Try our config only - and use this method to test -

Also, if this is a new machine, you can use -

That will save you from a lot issues!

Thanks, Rahul. I was already using your method to test it, and honestly, this method turned out to be just too big of a pain for the purpose. I've gone with WP-Super-Cache instead, and it's working fine now.

Glad to know you have working cache. Any pagecache is good.