Sitecore, Utveckling

Sitecore clear cache on site publish

When you publish a site in Sitecore, you might need to clear the cache on the web front server to be able to view your item changes.

The clear cache setting is configured in the web.config file in the site root. Here you need to specify all the sites you wish to activate cache clearing when you publish a site. You also have to specify all your sites in a site definition .config file under Sitecore\Website\Include\App_Config\. When you have a lot of sites to manage I prefer to keep one file up to date instead of two files separately.

This is the way to configure the web.config file and the site definition file:

Delete the <event name=”publish:end:remote”> from Sitecore\Website\web.config

      <event name="publish:end">
        <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
          <sites hint="list">
            <site>website</site>
          </sites>
        </handler>
      </event>
      <!-- publish:end:remote moved to separate config file Sitecore\Website\Include\App_Config\ProductionCD.config -->
      <event name="publish:fail" />

Put a site definition file ProductionCD.config in the Sitecore\Website\Include\App_Config\ directory with the following content:

The code is also attached as a separate file.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
		<events timingLevel="custom">
		  <event name="publish:end:remote" patch:after="*[@name='publish:begin']">
			<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
			  <sites hint="list">
				  <site>website</site>
				  <site>YourWebsite1</site>
				  <site>YourWebsite2</site>
			  </sites>
			</handler>
		  </event>
		</events>
	
    <sites>
      <site name="YourWebsite1" patch:after="*[@name='modules_website']" hostName="hostname1.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/Website1" startItem="/Home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false"/>
      <site name="YourWebsite2" patch:after="*[@name='modules_website']" hostName="hostname2.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/Website2" startItem="/Home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false"/>
    </sites>
    </sitecore>
</configuration>

,

By  -      


Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *