Nginx FastCGI caching NO PROXY We are implementing fast CGI cache (not not the proxy version) but it seems that our upstream cache hit is always MISS. If we hijack public/index.php by not running require_once($craftPath."/vendor/autoload.php"); and simply echo time the cache gets created and hit. We noticed that Craft adds cache control, pragma and expires headers by default. We tell FastCGI to ignore the headers with no luck.

Does Craft do anything to not allow FastCGI caching?

Thanks!

location ~ \.php$ {
    fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;
    fastcgi_cache cacher;
    fastcgi_cache_valid 200 60m;
    fastcgi_cache_methods GET HEAD;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
Found this while searching for a solution. I fixed it by moving this line to the top of the vhost file:

    fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;


After this all my requests are properly cached and my site loads really fast! My entire vhost file:

fastcgi_cache_path /etc/nginx-cache levels=1:2 keys_zone=phpcache:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_ignore_headers X-Accel-Expires Expires Cache-Control;

server {
        listen   80;
        charset utf8;
        root /home/user/htdocs/public;
        index index.php;
        server_name domain.com;

        set $no_cache 0;

        # Don't cache the CMS admin area
        location /admin {
                set $no_cache 1;
        }

        gzip            on;
        gzip_min_length 10;
        gzip_proxied    expired no-cache no-store private auth;
        gzip_types      text/plain application/xml application/x-javascript text/css image/svg+xml;
        gzip_vary on;

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass unix:/var/run/domain-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                fastcgi_cache phpcache; # The name of the cache key-zone to use
                fastcgi_cache_valid 200 30m; # What to cache: 'code 200' responses, for half an hour
                fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (ot POST)
                add_header X-Fastcgi-Cache $upstream_cache_status; # Allow us to see if the cache was HIT, MISS, or BYPASSED inside a browser's Inspector panel
                fastcgi_cache_bypass $no_cache; # Dont pull from the cache if true
                fastcgi_no_cache $no_cache; # Dont save to the cache if true
        }

         location ~ ^(.*)$ {
                 try_files $uri $uri/ /index.php?p=$uri&amp;$args;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg)(\?ver=[0-9.]+)?$ { expires 1w; }

        location ~ /\.ht {
                deny all;
                return 404;
        }
}