Caching is the secret sauce that can transform a slow page into one that loads blazing fast. There are many layers of caching – you can cache on the origin server, a POP endpoint, and even the browser. Using these techniques, you can obtain cache hit ratios of over 90% on networks like Cloudflare. However, these techniques are only effective for mostly static sites. As soon as there’s a dynamic component, you have to be very careful about what you cache. However, there are ways to work around this. And today, I came across a great WordPress plugin that makes it easy to exclude certain parts of a page from caching.
Caching Dynamic Pages is a Challenge
Let’s say your page shows the latest stock price. Or even the time or date. Perhaps you have a PHP snippet that calculates inventory or a plugin that synchronizes inventory between your online and physical store. None of these pieces of information can be cached. They must always be up-to-date – sometimes on a second-to-second basis. It’s a real shame because most of the time, you don’t want the entire page to be generated from scratch. It’s just a few elements that need to be dynamic while the rest of the page layout and text remain the same.
Fragment Caching Doesn’t Help
Plugins like W3 Total Cache have something known as “Fragment Caching”, where you can exclude certain items from the server cache. But if you use a system like Cloudflare to cache the page, fragment caching won’t help you, because Cloudflare stores the result of the server in its “Full HTML caching” functionality.
Using the Content No Cache Plugin
Recently, I came across this WordPress plugin that lets you create dynamic content that’s never cached – not even by Cloudflare when in full caching mode. It’s called Content No Cache. You can download and install it from the WordPress plugin repository.
After installation, you navigate to the “Content No Cache” section on the WordPress admin dashboard and create your dynamic content like this:
Now, of course, you could write a PHP snippet for this and insert it as a shortcode so that it computes automatically every time the page is loaded. Once you save this, you can use the provided shortcode to insert the dynamic content into a regular post/page. Like so:
And when the page renders, this is what you see:
This Even Works with Cloudflare’s “Cache Everything”
For me, this is the killer feature.
Full Site Caching is Now Accessible Even for Dynamic Pages
Full site caching is the magic sauce that can make even slow web pages load instantly. Using QUIC.cloud, NameHero users can reduce their TTFB times by as much as 500%! But it’s not particularly useful if your site depends on dynamic elements. Using the Content No Cache plugin, you can now extend full site caching even for moderately dynamic sites as long as you’re able to set it up properly with PHP in the backend to get the values in real-time.
This solution beats fragment caching as implemented on server caching plugins like W3 Total Cache. So go out there and use it!
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!