Configure HTML caching
How to improve the performance of websites by enabling the HTML output cache, including caching options to the renderings that Sitecore caches output for.
The HTML cache is an output cache that caches renderings, not whole pages. You use the HTML cache to improve the performance of websites.
To enable the HTML output cache:
sitespecification of predefined sites in the
sitesnode of the
\App_Config\Sitecore.configfile and set the
cacheHtmlproperty of sites to
trueto enable the HTML output cache for that site.Note
websitedefault site set up during installation is already there. You must specify this setting for any site you create yourself and that you want HTML caching for.Note
You can specify the size of each cache in the
htmlCacheSizeproperty of a site node.
Add caching options to the renderings Sitecore caches output for. You can do this in two ways:
Locally by specifying the options every time you use a rendering. To do this, open the item in the Content Editor, and on the Presentation tab, click Details, and then click the rendering you want to set options for.
Globally by specifying the options in the definition item of the rendering. This is then the default setting for all uses of this rendering. To do this, open the rendering definition item in the
sitecore/Layout/Renderingspart of the content tree, and navigate to the options in the Caching section.
The options are:
Specifies if Sitecore caches the rendering or not.
Clear on Index Update
Sitecore clears the cache when it updates the content search index.
This is important if your Sitecore instance uses HTML caching for renderings, controls, or sublayouts that contain code, and this code depends on an index. For more information, see Index-dependent HTML caching.
Vary by Data
Sitecore caches output based on the item accessed. This is useful when content is highly consistent, for example: headers and footers.
Vary by Device
Sitecore caches output for each device separately.
Vary by Login
Sitecore caches two copies of the output: one for authenticated users, and one for unauthenticated users.
Vary by Parameters
Sitecore caches output for each parameter the rendering accepts.
Vary by Query String
Sitecore caches output for each unique combination of query string parameters.
Vary by User
Sitecore caches output for each authenticated user.
In a standard Sitecore installation, Sitecore clears the cache on each publish. This is specified for the default website. If you add websites, you must patch the
Sitecore.configsetting like this:
Add the website to the
<event name="publish:end"> <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache"> <sites hint="list"> <site>website</site> <!-- the default site --> <site>yoursite</site> <!-- your site(s) --> </sites> </handler> <handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel" method="ClearCache" /> </event>