Keyhole caching tag that improves site performance
[%cache id:'uniqueid' type:'content'%] <p>[@sku@]</p> [%/cache%]
Creating a cache tag around a block of content saves everything contained in that block to Neto, meaning that dynamic tags or logic held within only need to be rendered once, before that result is then shown to every other use who calls that same block.
This block will then only be refreshed to reflect updates if either the cache is cleared from within the control panel or if the type is configured correctly, whenever the data tags within are updated in Neto.
Things to consider while implementing the
- The maximum size of each cached snippet is 1MB (not including images and other assets)
- Cached content should not include dynamic data such as customer details or cart details
- Cached elements are updated hourly or whenever you refresh your cache
type:''parameter is required and must have a valid value (cannot be blank).
Caching inventory thumbnails
Caching thumbnails is one of the most cost effective caches you can apply within Neto.
By using the
[@inventory_id@] data tag for the cache tag we ensure that along side the appropriate type tag, each thumbnail has its own unique ID
In the sample below we cache a
[%if%][%/if%] and store it to a thumbnail
[%cache type:'gallery' id:'[@inventory_id@]'%] [%if [@price@] > 100%]<p>Free shipping</p>[%/if%] [%/cache%]
Caching CMS controlled menus
When using the
menu tag to generate a menu that's statically defined via our CMS, you'll want to use the
type:'menu' which will ensure that if you update the CMS menu, the system will automatically find & clear the cache for this tag.
Caching automatically generated content menus
When using either the
content_menu or the now deprecated
category_menu tags - you'll want to use the
type:'cmenu' which will ensure that when any content in any content type is updated - the cache will be cleared to reflect the new category, blog, etc.
Note that if you are caching a menu that changes depending on the category you are on, for example, automatically being open when selected, you'll need a new ID for each state depending on the ID. The example below we use the
[@config:current_category@] data tag to ensure a unique ID for each state of the menu.
[%cache type:'cmenu' id:'mainmenu-[@config:current_category@]'%] <p>[@name@]</p> [%/cache%]
|id:''||String||The ID of the cache, two cache tags with the same ID & type will conflict and only load the first result rendered. The same ID on two types of cache tags will act as individual cache tags|
||By using types, this will enable specific behaviour within Neto to refresh a cache tag if the data tags within are changed in Neto.