Sitecore Html cache was not working even though cacheHtml attribute in site definition and caching.Enabled setting were true. Our site uses site definition inheritance. cacheHtml attribute was true in the parent's parent site definition.
Background on inherit attribute: Sitecore can inherit the site definition properties from another site definition. It is available for quite a while but it has been prominent after JSS site definition template uses it.
As per Sitecore's comments in Sitecore.config file:
inherits: Indicates that the attributes should be inherited from another site. To enable inheritance, you must specify the name of the source site. Attributes that are explicitly specified overwrite the attributes that are inherited from the source site.
As per stackexchange, there is no easy way to check the final Site definition after inheritance. Michael West (@MichaelWest101) posted a Sitecore PowerShell script to check it. As per the comment in the post, Sitecore gets the inherited properties from the immediate parent site definition. There is no logic to get it from the multi level site definition inheritance.
After we added the cacheHtml attribute to the immediate parent site definition, caching started to work. It is clear that only the immediate parent attributes will be inherited to the child child definition.
<sites>
<site inherits="website"
name="custom-common"
cacheHtml="true"
language="en"
.......
patch:before="site[@name='website']"/>
<site inherits="site1"
name="site1"
rootPath="/sitecore/content/site1"
startItem="/home"
patch:before="site[@name='custom-common']"/>
<site inherits="site2"
name="site2"
rootPath="/sitecore/content/site2"
startItem="/home"
patch:before="site[@name='custom-common']"/>
</sites>
No comments:
Post a Comment