fastcgi_cache + Wordpress = BYPASS only

I use Debian 7.5 with dotdeb repos.

I followed this guide:

And tested with this:

I always get BYPASS in my headers and cache details are not shown in the source of any pages and I have verified it is turned on in the wp-admin. The cache dir in /var/run/nginx-cache is always empty. I turned on logging but thelogs are empty. No errors in my nginx log either. Am really confused what could be the issue!

Seems like nginx-cache-purge is installed :

# nginx -V 2>&1 | grep nginx-cache-purge -o 

My nginx virtual host file:

#move next 4 lines to /etc/nginx/nginx.conf if you want to use fastcgi_cache across many sites
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;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

server {
        root /var/www/;

        access_log   /var/log/nginx/mydomain.com_access.log;
        error_log    /var/log/nginx/mydomain.com_error.log;

        index index.php;

        # Additional rules go here.
        # nginx fastcgi_cache settings:
        # POST requests and urls with a query string should always go to PHP
        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 / {
                try_files $uri $uri/ /index.php?$args;

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;

                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;

                fastcgi_cache WORDPRESS;
                fastcgi_cache_valid  60m;

        location ~ /purge(/.*) {
            fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";

        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe$
                access_log off; log_not_found off; expires max;

        location = /robots.txt { access_log off; log_not_found off; }
        location ~ /\. { deny  all; access_log off; log_not_found off; }


Interesting now it is making the directories in /var/run/nginx-cache but they are always empty:

# ls -al nginx-cache/
total 0
drwx------  5 www-data root     100 Jan 11 01:56 .
drwxr-xr-x 11 root     root     420 Jan 11 00:17 ..
drwx------  3 www-data www-data  60 Jan 11 01:55 a
drwx------  3 www-data www-data  60 Jan 11 01:55 c
drwx------  3 www-data www-data  60 Jan 11 01:56 d
# du -sh nginx-cache/
8.0K	nginx-cache/

Also turned on logging in nginx-helper but nothing useful there either. Totally confused with what I could check next :confused:

Well I have no idea why or how but this started working now. Yay! Please close this thread.