Caching page rules not working for WordPress

Hi.
I have two WordPress sites on a domain (CF free account). Main domain is evasovova.cz, subdomain is blog.evasovova.cz. Both are WordPress sites. I wanted to configure more aggressive caching via page rules. I have two rules now, one disabling caching, apps and performance for wp-admin. Second rule defines caching for wp-content/uploads folder to cache primarily all images.

I enabled the cache 10 hours ago, but I see no change on the analytics page.

I was expecting a significant increase of cached requests. There is no detailed info about cache hit/miss on the free pan though, so I cannot check what is going on.

Do you have any idea why I don’t see any change on number of cached requests after this change?

Hello,

Images, JS and CSS files, among other static assets, are cached by Cloudflare by default. The cache everything page rule is intended for when you want to extend the caching to assets that Cloudflare would normally not cache, mainly HTML pages.

As far as caching goes, neither of your two rules above are needed.

https://developers.cloudflare.com/cache/about/default-cache-behavior

Hi floripare.

That is interesting. Because the reason why I enabled the caching the way I did is my experience from my personal webpage - lukasberan.cz (static HTML page, no php, only html, JS, images). When I used the default config of Cloudflare, the amount of cached requests was very low. But when I enabled the cache everything option, it immediately raised to almost 100% of cached requests as you can see bellow between 7-8pm.

Based on that experience I started digging into how to increase caching for WordPress and found many articles on that topic. And followed specifically this one 8 Useful Cloudflare Page Rules for WordPress Sites (2021) (onlinemediamasters.com)

That’s the result of Cloudflare caching static files such as images, JS, CSS, which Cloudflare does by default, plus the page rule for caching everything, which adds HTML to the basket. The reason this site has so much cached, and the other two installs on your original post do not is that in all likelihood your page has a Page Rule that applies to the whole site, while the Page Rule for the other two installs applies only to the directory /uploads/, so it is actually instructing Cloudflare to cache everything where everything is already supposed to be cached.

Sorry, but that specific advice is plainly wrong. Please read the documentation provided in my first response, as well as: https://developers.cloudflare.com/cache/how-to/create-page-rules#cache-everything

2 Likes

Aaah, I see. So the only difference is the HTML files that are being cached when I set cache everything. But since WordPress does not produce any HTML files in the uploads folder, it does not make any change in the number of cached files/requests, because the uploads folder contains images purely and those are already cached by the default caching rules. Makes sense! Thank you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.