Whilst trying to implement some caching for a slow Wordpress site - I've enabled cachig at NGINX level.

However, it seems, that it's holding on to a rendered file, and doesn't want to let go.

It's not in the cache, I've tried reverting everything back, disabled SendFile to Off, however Nginx still wishes to serve a stale file from 5 days ago.

I've removed Nginx, re-installed it, re-build it, nothing.

Any thoughts?

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;

http {

        # Basic Settings

        sendfile off;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
include /etc/nginx/mime.types;
        default_type application/octet-stream;

        # Logging Settings

#       access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        # Gzip Settings

        gzip on;
        gzip_disable "msie6";

fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=NEN_CACHE:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri";

server {
        listen 82 default_server;
        listen [::]:81 default_server ipv6only=on;

        root /var/www/html/nen;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;

        location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_buffer_size 128k;
                fastcgi_buffers 256 16k;
                fastcgi_busy_buffers_size 256k;
                fastcgi_temp_file_write_size 256k;

                fastcgi_no_cache $no_cache;
                fastcgi_cache_bypass $no_cache;
#               fastcgi_cache drm_custom_cache;

                fastcgi_cache NEN_CACHE;
                fastcgi_cache_valid 404 60m;
                fastcgi_cache_valid 200 60m;
                fastcgi_max_temp_file_size 4m;
                fastcgi_cache_use_stale updating;
                add_header X-Cache $upstream_cache_status;


HTTP Request from CURL

HTTP Request headers

2 Answers 2


It appears the caching going on there is due to WP Super Cache, a wordpress plugin.

I would normally recommend you consult its documentation, but that plugin suffered an incredibly major vulnerability a few years ago that completely ruined any trust I had in the author. Personally, I would purge it from your server(s) with great prejudice and use a higher-level caching layer (like Nginx, as you're doing, or Varnish, which is excellent) as your sole full-page caching system.

  • I hate to say it, but thats since been removed. The cached version was produced by that, but its no longer present. I can even remove thr php/fpm lines, and it still returns the cached value. Mar 17, 2016 at 21:42
  • Obviously ill double check this! Mar 17, 2016 at 21:47
  • Rather embaressing - after much removing of plugins etc - and reinstalling and disabling - IT WAS the WP Super Cache :/ Mar 18, 2016 at 8:28

This isn't a straight out answer, it's to tell you how to work it out yourself. These things are often difficult to work out because you can't post everything.

Go back to basics. Remove all the extra tuning stuff from your PHP location. Use a simple PHP file that just calls phpinfo(). Try calling PHP via a socket, to see if it makes a difference. Check the PHP and nginx access and error logs for useful information. Once the basics work add in basic Wordpress, Nginx caching. I wouldn't bother too much with caching inside Wordpress unless you have a lot of logged in users, the Nginx cache will serve most of your site, most of the time. Do this in a separate directory, under a different nginx location, if you can't take down production.

This is how I call HHVM, my PHP interpreter, but I call php-fpm the same way you are.

upstream php {

# Inside my php location
fastcgi_pass   php;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.