Cloudflare is a pretty amazing service, and probably the only on that I know of with a free reverse proxy setup. For most website owners, its value comes from the caching service for static assets by default. I personally also use its DNS servers since I find their response times far faster than those used by my web host.
As just mentioned, Cloudflare automatically caches your JS, CSS, “woff” files (fonts) etc. You don’t need to explicitly specify this. These files are chosen for two very good reasons:
- They are static and don’t change often
- They are requested on almost all page loads for your site
Once these assets are in Cloudflare’s cache, you can use webpagetest.org to see how fast they load compared to the loading speeds from your own origin server. It’s not even close:
All of the assets in the screenshot are cache “hits” on Cloudflare. You can see that it takes between 43 to 69 milliseconds to search each resource. That’s very small. Most likely your origin server clocks in with several hundred milliseconds.
So “Cache Everything”?
This leads one to wonder why we simply don’t cache everything on Cloudflare instead of just static content. In its “Page Rules” section for example, we can force Cloudflare to cache the contents of all requests using the page rule:
Here, we tell Cloudflare to cache everything for 1 month (the maximum allowed).
This means that all of our web pages will be served from Cloudflare’s EDGE caches all over the world right? In fact, our origin server won’t even be touched! Right?
Not so fast.
“Cache Everything” Doesn’t Work Like You Think
Unfortunately, this simplistic page rule causes more problems than it solves. At best, it slows down your site. At worst, it actively harms it. Here’s why.
You’ll Show Admin Pages to Your Visitors
Even relatively static websites don’t show the same page to all their visitors. A prime example is logged in and logged out users. On WordPress sites for example, a lot of users have the Jetpack plugin which adds an admin bar when you’re logged in.
If you happen to visit a page on your site before anyone else, Cloudflare will cache that and show subsequent visitors the logged in version with the admin bar!
Now Cloudflare has an option to bypass the cache with a cookie. This would work great, except that it’s only available to Business users for $200 a month per domain!
Having said that, there are ways to disable the Cloudflare cache when you’re a logged in user. I’ll explore some methods in another article.
You’ll Slow Down your Site
The first hit to an EDGE cache is always a tad bit slower than a direct request to the origin server. That’s because the EDGE server needs to make the request to the origin server anyway in order to cache it for later. Cloudflare has 158 EDGE locations. That means each page of yours will have to be requested at least once from each of these EDGE locations to be completely cached everywhere.
If you have 100 pages on your site (a modest number), that means your site has to be pinged 158*100 = 158,00 times for it to be complete cached. And that’s assuming each request comes from a different combination of page and EDGE server!
The Content Won’t Be Cached
To make matters worse, all CDNs have some form of selective cache purging. If a resource is requested only infrequently, it will probably be removed from the cache and the server will request it again from the origin.
This means that pages which are infrequently visited will almost never get a hit on the EDGE cache. Even if they do get cached, they’ll just drop away at once.
Any Changes Will Reset the Cache
Finally, anytime you make the smallest change to your HTML, the entire cache will reset. It’s terrible!
Bottom line: Cloudflare’s free “Cache Everything” option looks seductive, but it just doesn’t work. Even if you manage to avoid showing admin pages to your users, it’s just extremely inefficient, and will actually slow down your site by adding an additional request to each and every ping to your origin server.
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
can you give idea what negative impact i may face if will use “Cache Everything” rule for my site. Its simple site. Using elementor plugin only one page where visitor lands and if click button a popup will appear and user will enter emal address and upon submit it will rediret to other web.
I plan whenever i want to change any tracking codes/pixel. I will use “Cloud Flare’s” Purge Every Page option and will also delete cache from WP Fastest case.
I will make sure to hit my site several times from the target audience location so CF will perform new cache (if this helps since i have deleted all cache sources)
In my case if i “ALSO” set “Edge Cache TTL = 2hrs” and “Browser Cache TTL = 30 minutes” what are the impacts or its not worth to do this.
Bhagwad Park says
If you use “Cache Everything” with a TTL of 2hrs, your speed will be absolute garbage! This option works well only if you have a page that hardly ever changes. Otherwise your site will actually SLOW down because most of the requests will be to prime the cache instead of serving it from POP locations.
So use this only if your TTL is at least a week (preferably more).
i cashed everything for my website and the performance is getting worst
Freddy Egoavil says
“Having said that, there are ways to disable the Cloudflare cache when you’re a logged in user. I’ll explore some methods in another article”
Where is the other article ?
Bhagwad Park says
See this article!
moslslat ramadan says
Where is the other article ??
Bhagwad Park says
See this: https://www.namehero.com/blog/how-to-reduce-your-ttfb-to-0-5-seconds/