How our cache works

Information about our cache and how it works.

Karl avatar
Written by Karl
Updated over a week ago

The Templ cache is a server level page cache, which comes pre-installed by us on all websites hosted by Templ. If needed, the plugin can be installed manually with the tool Install Templ plugins in our panel.

What is a Page Cache and how does it work?

Page caching stores the entire HTML of a page so that subsequent page views can be generated without WordPress (PHP + MySQL) having to generate the page.

When you load a WordPress page, WordPress has to process a large number of PHP files and query the database a number of times. For pages that aren’t constantly updated, this is wasted effort. It is much more effective to generate each page just once, then store that page and deliver the cached page to subsequent visitors. This is what page caching does.

Benefits of page caching include:

  • Much faster pageloads.

  • Scalability: Ability to serve more pages with reduced load for the server

Our servers use the nginx fastcgi cache module for page caching on server level.

What we cache by default

All pages without a query string in the URL, with a few exceptions:

gclid
fbclid
twclid
utm_term
utm_source
utm_campaign
utm_medium
utm_content
fb_action_ids
fb_action_types
fb_source

Following are all URL-paths that are never cached (and will always BYPASS the cache):

/wp-admin
/xmlrpc.php
wp-.*.php
/login
/logout
/signin
/signup
/register/
/cart
/my-account/
/wc-api/
/checkout
/addons
/lost-password


Note: The cache will be disabled if you are logged in to WP Admin.

Frequently Asked Questions (And Answers)

Q: How do I know if a page is loaded from cache or not?

A: You can test to see if your page is being served from Templ cache by looking at your HTTP response headers. Templ adds a X-Cache-Status header. Upon the first request to a non-cached page, it will display MISS.

Upon the second request to the same page, the X-Cache-Status header value will show a HIT, meaning it is being served from cache. 

The test above is done with Pingdom, but you can also check this directly in your browser. In Google Chrome, right click on your page and choose Inspect, then navigate to the Network tab and check the response header for the domain:

You can also check directly from your "Terminal" app with the following command:

curl -I https://templ.io


Q: Can I use the Templ cache along with another cache plugin like WP Rocket / WP Fastest Cache / Autoptimize...
A: Yes. Our cache works in conjunction with WordPress cache plugins, though we haven't tried every single cache plugins available, so you may need to do some testing and make sure your setup is working correctly.

Note: We do recommend using only one page cache at a time.

Out of all optimization plugins out there, we highly recommend using WP Rocket and Templ Optimizer along with our cache, for the best speed and score for your site.

Q: What is difference between WP Rocket / WP Fastest Cache / Autoptimize... and Templs page cache?
A: Unlike your typical cache plugin, our cache works on a server level for maximum performance and efficiency. Our cache plugin is merely a helper plugin that helps clear the cache as you make edits to your content.

Other WordPress cache plugins may have some nice tricks such as combining CSS and JS files to minimize the number of requests for each page load, as well as minification and other tricks to decrease the overall page size. 

Our page cache does not have these features since it would be unnecessary to replicate what so many others have already done.

Q: When is a page added to the cache?
A page is added to our page cache the first time it's visited, or the first time it's visited after the cache has been purged.

Q: How long time is a page cached?
A: The standard setting is 24 hours, but if you want to change this to a different value, just send us a message through the support chat and we'll change it to your preference.


Q: How do I manually purge (clear) the cache?
A: You can purge the cache from the Templ Cache settings, or from the shortcut at the top of the WP Dashboard:

The cache is also automatically purged when you make edits in WP Admin.


Q: How do I disable the Templ page cache?
A: To disable the Templ cache you just need to deactivate the helper plugin:

Did this answer your question?