wordpress-nginx icon indicating copy to clipboard operation
wordpress-nginx copied to clipboard

Only the index is cached, any other page are BYPASSED

Open Mayeu opened this issue 6 years ago • 4 comments

Hello,

I followed your tutorial to setup fast-cgi caching, and right now the

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

test makes caching to always fails for anything but the index.

The reason seems to be that when a post is loaded, the $query_string contains the path of the post q=/2018/07/28/never-cached/& (I use a header to see that: add_header X-query-string "$query_string";)

Thus, the page always return "BYPASS".

I am not sure how one could discriminate what should be cached in that case. Any idea?

Mayeu avatar Jul 28 '18 09:07 Mayeu

How about using pretty urls?

decimoseptimo avatar Nov 14 '18 18:11 decimoseptimo

@decimoseptimo Can you explicit what you mean? Note that I don't know WordPress that much, I am just a humble sysadmin :)

As far as I see at my server level, the way WordPress work is by turning the https://example.com/2018/07/28/article/ pretty URL into something akin to https://example.com/index.php?q=/2018/07/28/article/. Thus I am using pretty URLs, but the server still get a URL with a query at the end.

Mayeu avatar Nov 15 '18 06:11 Mayeu

I recommend you to fork this repo in your server so that you make sure this is your base. You'll notice that https://github.com/A5hleyRich/wordpress-nginx/blob/master/global/server/fastcgi-cache.conf defines the 4 scenarios that can trigger the BYPASS you see. I have no idea which one is affecting you, but for sure something in your codeis triggering it.

Comment out one at a time, reset nginx, and make tests.

decimoseptimo avatar Nov 15 '18 20:11 decimoseptimo

As I have said in my very first comment, what trigger the bypass is the query string check, which always trigger but on the home page :slightly_smiling_face:

Mayeu avatar Nov 16 '18 02:11 Mayeu