wordpress-nginx
wordpress-nginx copied to clipboard
Only the index is cached, any other page are BYPASSED
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?
How about using pretty urls?
@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.
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.
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: