Jaeeun Lee
Jaeeun Lee

Reputation: 3196

Disabled Cache for Static Content

I'm developing a Sitecore site on a local Windows 10 machine. I've try a couple of methods to disable caching CSS, but even in incognito the site shows cached styles.

Method 1: Web.config

<httpProtocol>
    <customHeaders>
        <remove name="X-Powered-By" />
        <add name="X-ETF-Spoofed-IP" value="xx.xx.xxx.xxx" />
      <add name="Cache-Control" value="no-cache" />
    </customHeaders>
</httpProtocol>
<staticContent>
    <clientCache cacheControlMode="DisableCache" />
</staticContent>

Method 2: in IIS: Set Common Headers as Expiring Immediately.

Could there be something missing? The stylesheets are being bundled.

There is this code in Index.cshtml that I didn't write:

if (pageItem.TemplateID == Templates.GenericPageTemplateId || pageItem.TemplateID == Templates.GenericMicrositeTemplateId)
{
    headerCss = "generic-header";
}

Using Visual Studio.

Upvotes: 0

Views: 688

Answers (1)

Nas
Nas

Reputation: 352

In addition to what Gabriel mentioned, there are some cache settings based on how you render the contents having CSS stuff. As you said that you want to disable CSS cache and it means you updated CSS file linking to the page. We also have many Sitecore front-end developers and they have similar issue you are facing.

Have you refreshed the page by checking "Disable cache" (Network tab) in Developer Tool?

enter image description here

If you refresh the page with opening Developer Tool, the page renders without any stored cache information. There is another setting to disable HTML Cache in its web.config file, but I guess the issue is not from there.

Upvotes: 1

Related Questions