0

I am trying to disable cache for all Sitecore pages. I am able to do this through the code (through shared layouts) but I wanted to do it through just the config file. I came across many posts that mentioned setting DisableBrowserCaching = true in web.config would add no-cache, no-store to the response header. However, in my case it takes no effect.

I was wondering is there anything else I need to do along with setting DisableBrowserCaching = true?

Edit: Everything under caching section in content editor is unchecked.

8
  • 1
    Possibly answered here: sitecore.stackexchange.com/questions/2207/…
    – Mark Cassidy
    Commented Jan 30, 2017 at 21:23
  • Could you please verify that the configuration is not overriden by a patch to check /sitecore/admin/showconfig.aspx? Commented Jan 30, 2017 at 21:29
  • @MarkCassidy - Unfortunately not :( . Commented Jan 30, 2017 at 21:33
  • @TamásTárnok - Nope. It is not being overwritten. Commented Jan 30, 2017 at 21:35
  • Do you have cahcing.enabled set to true? If yes try making it to flase reset app pool and see what happens with other settings as it <!-- CACHING ENABLED Determines if caching should be enabled at all Specify 'true' to enable caching and 'false' to disable all caching --> <setting name="Caching.Enabled" value="true" /> Commented Jan 31, 2017 at 15:28

1 Answer 1

1

I assume you are building an MVC based site?

if so the renderLayout pipeline is not used, and this is where the Sitecore.Pipelines.RenderLayout.BrowserCaching function is called from, so since it isn't called, it will not have any effect

you could disable caching for all actions in a controller, or specific action as below:

[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)] // will be applied to all actions in MyController, unless those actions override with their own decoration
public class MyController : Controller
{
  // ... 
}

Disable for a specific action:

public class MyController : Controller
{
    [OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)] // will disable caching for Index only
    public ActionResult Index()
    {
       return View();
    }
} 
0

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.