I am planning to move away from the Jetpack CDN Photon due to Cloudflare. Will these settings make sure my images are cached?
Got this setting from here: https://onlinemediamasters.com/Cloudflare-settings-for-wordpress/#page-rules
Thanks!
I am planning to move away from the Jetpack CDN Photon due to Cloudflare. Will these settings make sure my images are cached?
Got this setting from here: https://onlinemediamasters.com/Cloudflare-settings-for-wordpress/#page-rules
Thanks!
Um… Am I completely missing something here?!?
Seems to me that this page rule will do exactly the opposite of what you want…
Setting the cache level to bypass means you are NOT using Cloudflare caching there…
Ah, ok. Sorry, I am new to Cloudflare.
How can I set it so that images are immediately cached?
Sorry about that!
nope… that part of the guide you linked to does appear to be incorrect to me, so wasn’t you!
Would that be a better option? If I update an image, does the site alert Cloudflare to the change?
Thanks
@domjh is right, and you actually do not need any page rule for the assets under /wp-content/uploads/
Cloudflare will cache by default static files, you can check all file types that are cached here:
You would need a page rule to make Cloudflare cache the generated HTML of a WordPress website. If your content is static and doesn’t vary based on login status, you can create a page rule with a Cache Level: Cache Everything
setting, like the one you just posted, except it would need to apply to the whole site:
URL: *.example.com/*
Cache Level: Cache Everything
etc.
Great, my site is mainly text based as its a review site. If I made an update, would Cloudflare pick this up and clear the cache for the site homepage?
Thanks!
It will if you use the Cloudflare Plugin and switch on the Automatic Cache Management on the plugin’s settings tab.
Also, you would need another page rule to exclude /wp-admin/ area from caching. I like to do it this way:
URL: *.example.com/wp-*
Rocket Loader: OFF
Disable Apps
Security Level: High
As long as this rule is placed above the one for caching everything, it should make CF avoid caching the /wp-admin/ area, as well as /wp-login.php and /wp-json.php. Please notice that I did not include a Cache Level: Bypass setting, to avoid bypassing cache for /wp-uploads/. As long as that is placed before the page rule for cache everything, it should work fine.
The page rule I suggested for cache everything is slightly different from the one you posted previously, please check my edit to my previous post.
Okay, I will install the plugin. Does it have any impact on the front end speed of the site?
Also, if I am on the www
subdomain do I need to use *.thenerdystudent.com/*
or thenerdystudent.com/*
?
Thanks!
Not that I could notice in testing with GTMetrix. Of course any plugin adds some time to the processing of the page, but this should be very small and it will only impact the visits CF makes to your site whenever the cache expires.
If you are using the www., I’d suggest you set the URL as:
www.example.com/wp-*
www.example.com/*
But you should have another page rule (and place it above the two we were talking about) to redirect from naked domain to www. For that you should use only one setting, Forward URL:
From: example.com/*
To: https://www.example.com/$1
Great, thanks!
Wordpress seems to do this automatically, with https://thenerdystudent.com being redirected.
Thanks for the help, is this a good option?
I am installing the plugin so it should be updated on updates.
Thanks!
I normally set browser cache to a day or less, because while you can always purge the edge (Cloudflare server) cache, the same is not true for what’s in the visitor’s browser.
At the same time, I normally set the edge cache for a month. But the cache may be dropped from the edge sooner for any page that is not visited frequently.
Thanks, implemented the rules. Appreciate the help!
You’re welcome.
You should perhaps now be a good netizen and tell the guys from that blog that their advice concerning /wp-content/uploads/ folder is wrong!
I think they had the best of intentions and the other settings may be helpful for this folder, but Cache Level: Bypass
is certainly not, as first pointed by @domjh.
I already have
Wonderful!
@domjh, you’re faster than Cloudflare, man!
That set of rules in the guide look very wrong. First…cache everything. And then don’t cache a couple of things. Those no-cache rules won’t even take effect.
So, @dipperdolphin, if you’d like to post a screenshot of your group of Page Rules, we can take a look to see if there are any conflicts.
Thanks! I have sorted out the rules now, just have one final question. I use Autoptimize for CSS and JS, and they always appear to be expired. Any way I can change this?
Would a rule pointing towards ../cache/autoptimize/*
fix this? What would be the best settings to put here?
So my rule where I cache everything, I have the Cloudflare plugin. When I make a new post, or edit my theme, will the Cloudflare cache be purged and viewers see the new item despite their Browser cache TTL?
Thanks!
The Autoptimize cache should also be automatically purged when you use the Cloudflare Plugin, according to its documentation. So if you’ve been making changes to your pages, the Autoptmize-cached files may have been purged. You should not create a page rule for that, in my opinion, as CSS and JS files are cached by default, whether generated by AO or not.
You may want to hit Purge Everything a couple times to see if the problem goes away.
This is hard to answer. The best practice here would be to keep the Browser TTL setting to a day or less (I have it set to 4 hours in my sites), to make sure changes are quickly picked up.
Thank you!
@cbrandt, may I ask what your Edge Cache is? Thanks