Rendering Caching (SCORE Auto Cacher)
Intro
Caching - One of the most effective ways to improve your website response time. It is also one of those topics that is challenging to discuss without a developer.
With the release of SCORE 3.1.4.0, we have made the lives of developers and content authors a bit easier! We have introduced a tenant-level cache setting that can be configured by a developer during the active development phase.
Levels of a rendering caching
For a rendering to be cacheable, it's "Cacheable" checkbox field must be checked. There are 3 locations where this checkbox can be set: on the Rendering Definition item, in the Component Properties dialog, and now under the Tenant Settings folder.
The location where a rendering is set to be cacheable determines the scope of the rendering's cacheability.
Global
checked on the Rendering Definition Item itself- Sets the rendering to always be cached, regardless of where it's used
- Use with caution when configuring cacheability settings for reusable renderings
- NOTE: Score does not enable this for ANY components. Custom components have also not been set to use global caching.
Site Level
checked for the selected rendering in the Caching folder under the [Tenant] Settings folder- Sets the rendering to be cached and overrides global caching settings.
Instance
checked in the rendering's Control Properties dialog- Sets the instance of the rendering to be cacheable
- Does nothing if rendering is globally cacheable
- Overrides global and site level cache setting if Override Cache Settings checkbox is checked
- Supports versioned layouts, in Sitecore 8, 9:
- Set for particular item versions via Final Layout
- Set for all versions via Shared Layout
- Can and should be set in the Presentation Details of a page template's Standard Values.
- Can and should be set in the Presentation Details of a branch template.
Caching Options
Options | Provided By | Description | Most Useful When | Used in practice... |
---|---|---|---|---|
Override Cache Settings | SCORE | Overrides caching options set globally or on a tenant level. This setting makes a cache hole in outer components and force the current component to renders itself with the cache settings specified for it. | ||
Cacheable | Sitecore | Sitecore enables caching for a rendering only if this checkbox is selected. Unselected checkbox together with selected "Override Cache Settings" works as a cache hole (in case if a parent component cached) and forces the component to be always rendered. | ||
Clear on Index Update | Sitecore | Property controls whether or not a control clears its cache when an item that is associated with the control is updated in the index. The rendering will be cleared from the HTML Cache when an item that is associated with the rendering is updated in the index. Renderings are cleared from the cache by the | Your rendering contains code that depends on an index, e.g. components that display details of an item retrieved via server side ContentSearch
For example:
If someone updates the price of one of the products on special offer, the Clear on Index Update property will the trigger the control to clear its cache because something has been updated in the index that is bound to the control. | Rarely |
Vary by Data | Sitecore | Sitecore caches the output based on the item accessed. When the same item is accessed for the second time, the HTML will be loaded from the cache. Sitecore will cache the rendering's output once for each data source, including no data source. | Content has a datasource and not dynamic, such as headers and footers, navigations. | Often |
Vary by Device | Sitecore | Sitecore caches copies of the output for each device being used. | A dedicated device layout has been created to serve up smartphones. Not used in responsive design. | Rarely |
Vary by Login | Sitecore | Sitecore caches two copies of the output. One is for authenticated users, and one is for unauthenticated users. | Sites require registration but present the same content to all users once loged in. | Occasionally |
Vary by Param | Sitecore | Sitecore caches the output for each parameter accepted by the rendering. | You are making use of rendering parameters. | Rarely |
Vary by QueryString | Sitecore | Sitecore caches the output for each unique combination of query string parameters. | Most commonly needed when forms or other functionality have been embedded into the site. Sitecore will cache based on the values that appear after any ? in the url. | Rarely |
Vary by User | Sitecore | Sitecore caches the output for each authenticated user. | Personalized sites that deliver unique experiences to each user. Be mindful when using this setting, as it can eat up the cache storage quickly. | Rarely |
Vary by Page | SCORE | Sitecore will cache the rendering's output once per page. | Your rendering is on standard values and wraps content that changes per page. A good example of this is the Header Snippet on top of all pages and has a navigation component with a current page highlight. | Often |
Setup Caching
In the Experience Editor
To access the caching options for a component (page level settings), open it's component properties:
In the Content Editor
If your Sitecore content tree is scaffolded using SCORE Tenant Scaffolding Automation, you can add to a new Caching folder to your Settings folder based on /sitecore/templates/Score/Caching/Site Caching Settings Folder. If you have a custom content tree installation, just add the Caching folder to a folder which #settings# token points to (you can find resolvers to #settings# token by the path: /sitecore/system/Settings/Rules/Get Lookup Source Item).
Extend Customization
As always, it is easy to extend rendering cache customization via your custom pipeline processor.