12

I am currently making code changes to a view rendering in Sitecore, and when a deploy these changes to my local environment, they were not visible. I realized that the rendering was marked as Cacheable, so I was seeing a previously cached version.

Rendering Caching Settings

Besides unchecking Cacheable on the renderings I'm currently working on, what would be the best way to disable HTML caching for development?

13

I typically disable caching for my local environment by setting the HTML cache lifetime to 1 second using the following config patch:

<setting name="Caching.HtmlLifetime">
  <patch:attribute name="value">00:00:01</patch:attribute>
</setting>

To make this specific to your local environment, you can patch it in using a configuration transforms or using a tool like Slow Cheetah

  • While the rest of the answers are great, I'm choosing this one because it's specific (only affects HTML caching) and easy to implement in a multi-site solution. – JohnD Sep 16 '16 at 18:33
  • 3
    In my opinion not the correct answer, as it affects the complete environment. The answer by disabling cacheHTML=false in the site node, is better, as it disables the cache for a specific site. – Bas Lijten Sep 19 '16 at 16:05
  • 1
    @BasLijten for me, that is a positive. This is for local development, and I do not want to disable cache for specific sites. In some cases, I may have 30+ site definitions. – Derek Hunziker Sep 19 '16 at 17:33
  • 1
    Yes, the question was focused on what to do in a development situation and not the best way to disable caching in production. – JohnD Sep 20 '16 at 14:14
  • 1
    Also ensure iis level user and kernel cache is not enabled. – Santosh Poojari Sep 20 '16 at 22:57
18

You can turn cache off at the site level in the site definition in configuration:

<site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" />

Simply make sure "cacheHtml" is set to "false".

9

I typically do what you're doing and set all the renderings I want cached to be cacheable. However, for my local development, I will set cacheHtml to false on the site definition.

 <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
   <sitecore>
     <sites>
        <site name="mySite" patch:before="site[@name='website']"
          ...
          cacheHtml="false"            
         />
      ...
  • This is my preferred method too. Typically I will have a configuration file that is for development environments only (i.e. not deployed) that overrides the default site definition to patch this attribute. – Kasaku Sep 19 '16 at 16:44
3

Looking for Caching.Enable in your web.config. You can change it to false via a patch, transform, etc.

  • Correction -- It's Caching.Enabled – mluker Sep 16 '16 at 18:27
  • 2
    This will disable ALL Sitecore caches. Whilst this will include the HTML cache I'd consider it overkill for this siutation when there are means to just disable the HTML caching. – Kasaku Sep 19 '16 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.