13

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?

4 Answers 4

17

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

9
  • 1
    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
    Commented Sep 16, 2016 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
    Commented Sep 19, 2016 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. Commented Sep 19, 2016 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
    Commented Sep 20, 2016 at 14:14
  • 1
    Also ensure iis level user and kernel cache is not enabled. Commented Sep 20, 2016 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".

10

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"            
         />
      ...
1
  • 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
    Commented Sep 19, 2016 at 16:44
4

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

2
  • Correction -- It's Caching.Enabled
    – mluker
    Commented Sep 16, 2016 at 18:27
  • 3
    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
    Commented Sep 19, 2016 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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