Why you should use Blitz and Cloudflare with Craft CMS
From the Journal – Posted 15.11.2024
At Mud, we are enthusiastic supporters of the Blitz plugin, and the overwhelming majority of our Craft CMS websites rely on this plugin (developed by Craft plugin experts Put Your Lights On), to generate and sustain static cached versions of web pages.
How Blitz improves performance, user experience, and scalability
Blitz caches web pages as static HTML files, which means the server doesn't have to generate the page dynamically for every request. This significantly reduces server load and allows the site to handle much more traffic as the process of calling content from the CMS database can slow things down.
Users experience a much faster and smoother browsing experience due to faster page loads. This is particularly important for user engagement and can lead to lower bounce rates.
And maintaining cached pages makes a huge difference to your hosting setup as you can handle much more visitor traffic when you're delivering cached pages rather than pages that have been generated by Craft on every request.
Check out the Blitz docs for an explanation of how it all works.
Static caching and a global CDN
When used with a global CDN like Cloudflare, Blitz ensures that cached pages are stored on servers all over the world. This means visitors will receive the cached page from a server that is geographically closer to them, resulting in even faster load times. This is where Cloudflare comes in.
By using Cloudflare to host the DNS of a domain, we can enable its static caching feature, which will store a copy of a website page in its own architecture. Visitors to a cached page aren't even going to get as far as your web server at all.
This further increases the scaleability of your website, reduces your hosting costs, and squeezes a makes things even faster.
Measuring the difference
If you run a test on a website page with Google's Page Speed Insights in the following situations, you'll see a huge improvement when Blitz serves a cached page, and an incremental improvement when you then enable Cloudflare and test again.
- Blitz off, Cloudflare off = slow.
- Blitz on, Cloudflare off = much, much faster.
- Blitz on, Cloudflare on = a little faster again.
Is it worth adding Cloudflare static caching to a page that's already cached with Blitz?
Well, whilst the incremental improvement may appear relatively small in tests, the difference can be significantly larger when your website is visited from other locations around the world.
Cloudflare also provides plenty of other features to optimise performance and speed things up further:
- Rocket Loader optimizes JavaScript delivery by deferring scripts and ensuring the critical content loads faster.
- Auto Minify reduces file sizes for HTML, CSS, and JavaScript by removing unnecessary characters.
- Brotli Compression enhances compression beyond Gzip for smaller file sizes and faster transfer.
- Features like Polish optimise images by compressing and serving in modern formats like WebP.
Why not just use Cloudflare without Blitz?
The great thing about the Blitz and Cloudflare pairing is that Blitz has the intelligence to know which cached pages need to be cleared whenever you update content in Craft. It's often not as simple as just clearing the cache for one particular entry - that entry might also appear on listing pages and as a featured entry on a number of others. Blitz keeps a track of all of this, and clears the relevant pages when needed.
With Cloudflare enabled, Blitz will then also trigger a purge of any pages that need to be cleared from Cloudflare's cache, so visitors will see your updates. *
Without Blitz, you'd need another way to manage this cache clear process.
* You can also set Blitz to only clear cache periodically rather than automatically, which may be an important consideration when managing very large websites.
It's not all about the cache
There are so many other Cloudflare benefits - particularly for security and threat detection - we really think it's a no-brainer when it comes to choosing to host your DNS with them, and to pair Blitz with Cloudflare to make your website user exerience as fast as possible.
Looking to turbo-charge your Craft website?
With well over 100 Craft websites designed and built to date, we have an expert understanding of how to get the best out of your Craft CMS website. And we're always happy to share our advice on how you can improve your existing site, or approach a new build.