WP Super Cache won’t cache pages other than home pageIn WP Super Cache’s configuration tab “Advance”, it shows:
1234 Add here strings (not a filename) that forces a page not to be cached. For example... wp-.*\.phpindex\.php
And by default (at least for my configuration) WordPress sets Permalink as /index.php/%year%/%monthnum%/%day%/%postname%/
. Hence all the posts are “rejected” according to the rule above. Logs confirm this:
123 00:00:01 10000 /index.php/2019/01/01/... wpcache_do_rebuild: exiting as directory is not a directory: ...00:00:01 10000 /index.php/2019/01/01/... URI rejected. Not Caching 00:00:01 10000 /index.php/2019/01/01/... wp_cache_maybe_dynamic: returned $buffer
It’s possible but not recommended to remove index.php
from the reject list for SEO purpose. So I changed Permalink and got a … 404.
For Permalink without index.php
to function properly in nginx, It’s necessary to change nginx’s configuration, by adding the following to server
section:
123 location / { try_files $uri $uri/ /index.php?$args;}
After fixing the Permalinks, the pages are cached properly, and can be confirmed by the comments in pages’ source:
12 <!-- Dynamic page generated in 0.500 seconds. --><!-- Cached page generated by WP-Super-Cache on 2019-01-19 00:00:00 -->
In WP Super Cache’s configuration tab “Advance”, it shows:
1 2 3 4 | Add here strings (not a filename) that forces a page not to be cached. For example... wp-.*\.php index\.php |
And by default (at least for my configuration) WordPress sets Permalink as /index.php/%year%/%monthnum%/%day%/%postname%/
. Hence all the posts are “rejected” according to the rule above. Logs confirm this:
1 2 3 | 00:00:01 10000 /index.php/2019/01/01/... wpcache_do_rebuild: exiting as directory is not a directory: ... 00:00:01 10000 /index.php/2019/01/01/... URI rejected. Not Caching 00:00:01 10000 /index.php/2019/01/01/... wp_cache_maybe_dynamic: returned $buffer |
It’s possible but not recommended to remove index.php
from the reject list for SEO purpose. So I changed Permalink and got a … 404.
For Permalink without index.php
to function properly in nginx, It’s necessary to change nginx’s configuration, by adding the following to server
section:
1 2 3 | location / { try_files $uri $uri/ /index.php?$args; } |
After fixing the Permalinks, the pages are cached properly, and can be confirmed by the comments in pages’ source:
1 2 | <!-- Dynamic page generated in 0.500 seconds. --> <!-- Cached page generated by WP-Super-Cache on 2019-01-19 00:00:00 --> |