Monday November 10th 2025
ExpressionEngine Tag Caching
I've recently had an interesting project, that required the checking of a 3rd party site to confirm that a user was allowed access to read certain pages. To do this, I wrote a simple Addon, with a single tag that performed the check, by requesting a specific url (basically exampledomain.tld/check/{magiccode}/{anothercode}). Upon success that page would return either a positive response or a negative one.
With my performance hat on, I started to think “Do I really want this running on every page.. potentially waiting for a 3rd party site to respond?” This sent me down a little rabbit hole of learning, this time about ExpressionEngine “Tag Caching”. What is this thing? Well the current ExpressionEngine docs say :
The Tag Caching system lets you cache the output of individual tags. This enables you to display sections of your pages completely dynamically while leaving others to display statically. By caching individual tags you will reduce the amount of scripting and server resources needed to display any given page while maintaining a fully dynamic presentation for things that require it.
Tag caching is time-based, meaning the cache is used for a user-definable time interval. When the time expires, the cache is automatically refreshed.
![]()
Tag Caching lets you take the strain off a server, this has to be a good thing!
What I wasn't sure about was how specific that cache could be, but a dig into the core code, let me to this part of the file “system/ee/legacy/libraries/Template.php” the key take away was seeing that it does cache with a key of the actual tag, and importantly the parameters as per:
// Check the tag cache file $this->cache_prefix = (isset($this->tag_data[$i]['params']['cache_prefix'])) ? $this->tag_data[$i]['params']['cache_prefix'] : ''; $cache_contents = $this->fetch_cache_file($this->tag_data[$i]['cfile'], 'tag', $this->tag_data[$i]['params']);
This means that if I set up the tag parameters, then they would be cached separately i.e. the following two are treated as two unique things to cache:
{exp:myAddon:myTag magicOne="123" magicTwo="345 cache="yes" refresh="10"} is cached apart from {exp:myAddon:myTag magicOne="987" magicTwo="654" cache="yes" refresh="10"}
Happy days!
