Template Tags


Fragment caching uses a tag pair to cache a specific block of content, as opposed to the entire page when using Static caching. You can put anything you want inside of a {exp:speedy:fragment} tag pair, including {embed}, {exp:channel:entries}, or any other ExpressionEngine tag.


  • driver="dummy|file|redis|memcache|memcached" The name of the cache driver you want to use for this specific instance of the fragment cache tag. This will override the default global setting in your config.php file. If not defined, the global driver defined in $config['speedy_driver'] will be used. (Default: "")

  • global="yes|no" Whether this item should be cached globally or not. Non-global items use the current url as part of their key. (Default: "no")

  • key="featured_item"The key for the item cached in this tag pair. If this key is used for a non-expired cache item, the content of that item will be used instead of parsing the content of the tag. (Required when global="yes") (Default: "item")

  • ttl="3600" The number of seconds before this cache item with expire. If left blank the default TTL (1 hour) will be used. Use ttl="0" to cache this item until the cache it broken. (Default: "")

  • tags="apple|orange|etc" A pipe-separated list of tags to apply to this item. Tags can be used in the cache breaking settings. (Default: "")

  • url_override="path/to/page"Override the url used as part of the key for non-global items. (Default: "")

  • url_prefix="something"Add a prefix to the key. Useful for multi-lingual sites, e.g. url_prefix="{publisher:current_language_code}" (Default: "")

    • If using Publisher, and you are not displaying the default language segment in the URL, you may need a conditional similar to the url_prefix parameter: url_prefix="{if publisher:current_language_id != publisher:default_language_id}{publisher:current_lang_code}{/if}"


... content to be cached ...


When using fragment caching, it may be desirable to prevent certain sections of the template that are inside your {exp:speedy:fragment} from being cached. ExpressionEngine will still parse the contents of an escape tag every page load.


Some template variables such as {segment_*} are always parsed before the module. For these tags we have implemented pre-escaping using a core extension.

To use pre-escaping, add a unique suffix to the tag.


... content to be cached ...
{!-- Regular escape --}
{if logged_in}
You are logged in
You are not logged in
{!-- Pre-escape --}
You are on the {segment_2} page
... content to be cached ...

Template Layouts

Using ExpressionEngine's {layout} feature works as expected if you are using the Static cache driver, or Redis with static enabled, but if you are using fragment caching you'll need to cache your layout file as a separate global cache item, and escape the {layout:contents} tag. For example:

{exp:speedy:fragment key="global-layout" global="yes"}
<!-- global navigation -->
<!-- global footer -->

Then inside your template:

{exp:speedy:fragment key="{segment_3}"}
{exp:channel:entries url_title="{segment_3}"}
{layout:set name="page_title"}{title}{/layout:set}
{layout:set name="some_meta_data"}Some value here{/layout:set}
<!-- custom fields to render the page content -->

This technique will result in an additional cached item for each layout that is globally cached. Custom layout variable tags (e.g. anything other than {layout:contents}) unfortunately can not be inside of an {exp:speedy:fragment} tag in your main layout file, which means you can't use fragment caching for the entirety of your layout file, but depending on your layout file you should be able to cache the majority of it. If you need to cache your entire layout file, then static caching may be a better strategy than fragment caching.