5

I have configured and tuned site caches many times, but I feel like I still don't fully understand what the DisableBrowserCaching setting does. I have read all of the docs and I have done a little research on the Cache-Control: no-cache, no-store Pragma: no-cache headers, but it seems like everything I read assumes that I already know what it is that I'm looking to disable caching for.

Sitecore's documentation states the following:

When DisableBrowserCaching is true, Sitecore sets the following HTTP headers for each requested item (excluding media items):

Cache-Control: no-cache, no-store Pragma: no-cache

These HTTP headers instruct Web clients, including edge-caching devices, not to cache the page. Web clients can cache CSS, media, and other resources used by the page

From what I can tell, this is saying that media, CSS, JS, etc. will still be cached, but the "page" won't be. What I am struggling to find is confirmation on what exactly the "page" is.

It looks like the "page" is supposed to refer to the actual HTML of the page. This would make sense, since Sitecore defaults DisableBrowserCaching="true", and a Sitecore site doesn't often include pages that have entirely static HTML.

Can anyone help to clarify this setting for me and maybe provide a situation or two when it would be set to false?

7

You have it right, the Page refers to the fully rendered HTML Markup of the page. This would include all renderings on that page that are not ajax'd in after the page load in the browser.

media, CSS and JavaScript MAY still be cached, but it doesn't mean they WILL be cached. You have to setup the cache control headers for static assets outside of Sitecore. You can do this in IIS via the web.config file. Add a section under system.webServer:

<system.webServer> 
    <staticContent>
       <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
    </staticContent>
</system.webServer> 

In this example all static files will have a max age response header set to 1 day.

Remember that this only suggests to the browsers how long they should cache the content for. Browsers do always follow it, for example if Chrome has the dev tools open, there is an option to disable the browser caching there.

  • 2
    Important to know: personalisations will be cached as well, when turned on. Only turn on when content doesn't change, your HTML doesn't change and no personalizations are used, in any other cases, I would never allow the HTML to be cached. – Bas Lijten Nov 4 '16 at 12:26

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.