Caching HTML can help you reduce the overall page load speed, as the CDN can hold your HTML rather than have to request it from the server each time.
There are pros and cons to doing this, but if you’re a static site that doesn’t change too often, caching your HTML could be the perfect solution to improving page load speeds a bit.
Does Cloudflare cache HTML?
Yes, however not by default. You need to enable it with the below steps to create a page rule.
How to cache HTML with Cloudflare
Caching HTML in Cloudflare is easy, so just follow these steps.
1. Open cloudflare, and click ‘page rules’ in the sidebar
2. Click ‘create page rule’ to the right of this page
3. Insert your sites domain with a wild card on the end, just like the cloudflare example, and then select ‘Cache Level’ and ‘Cache Everything’ from the dropdowns.
And you’re done!
You should be able to run a test now, and compare to before HTML caching.
For me, here is my test.
Before HTML caching
After HTML caching
Yes, the site is already optimised, but a few key metrics were improved even further.
FCP dropped from 305ms to 112ms.
TTI dropped from 305ms to 112ms.
LCP dropped from 500ms to 444ms.
Not too bad at all!
Is it good or bad to cache HTML with Cloudflare?
It really depends. How static is your content?
If you have an extremely dynamic site, or even a news homepage style site, caching HTML might not be good for you.
Rather than a consumer constantly getting fresh content, they will get the HTML cache version until the cache is refreshed. This means they’ll only see the content available at the time of cache, and not anything that has been added or edited since.
Not just consumers, but Google too. We want Google to have the freshest content, so you might be holding yourself back by a day or two, along with annoying users, if you enable HTML caching.
However, if you’re site is extremely static, HTML caching can really help you knock off a few hundred milliseconds off some key core web vital numbers.
Use HTML caching wisely, and it can help you improve your page load speeds… provided you’re a good fit for it.