rija / docker-nginx-fpm-caches-wordpress

Wordpress (no DB server included) running with Nginx in a Docker container with caching and encryption enabled
Other
23 stars 7 forks source link

Only the home page is cached by the FastCGI cache #1

Closed rija closed 8 years ago

rija commented 8 years ago

Whenever I load a page in my browser that is not the home page, the page is served from the server instead of from the cache, always. The response header contains:

X-Cache-Status:BYPASS

After enabling debug level:

error_log    /var/log/nginx/error.log debug;

I can see this:

2015/08/05 07:05:11 [debug] 115#0: *371 http script var: "q=/en/my-page/&"
2015/08/05 07:05:11 [debug] 115#0: *371 http script value: ""
2015/08/05 07:05:11 [debug] 115#0: *371 http script not equal
2015/08/05 07:05:11 [debug] 115#0: *371 http script if
2015/08/05 07:05:11 [debug] 115#0: *371 http script value: "1"
2015/08/05 07:05:11 [debug] 115#0: *371 http script set $skip_cache
rija commented 8 years ago

That trace looks like the exectution of this block of the site specific config:

    if ($query_string != "") {
            set $skip_cache 1;
    }

which make this line of the site specific config likely the culprit:

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

This is the problem. it should be:

    try_files $uri $uri/ /index.php?$args;