Base solution for your next web application
Open Closed

Index.html caching #5126


User avatar
0
JapNolt created

We were having an issue where we would make a change to a css class for an element and after deploying the code the changes did not show unless you did a Ctrl + F5 to prevent loading from the cache.

We discovered the index.html file was being cached which was why we did not see our changes when doing a typical refresh. We found a fix which involves modifying the web.config file to not cache the index.html file like this:

<location path="index.html">
<system.webServer>
  <staticContent>
    <clientCache cacheControlMode="DisableCache" cacheControlMaxAge="0.00:00:00" />
  </staticContent>
    <httpProtocol>
        <customHeaders>
            <add name="Cache-Control" value="no-cache, no-store, must-revalidate" />
            <add name="Pragma" value="no-cache" />
            <add name="Expires" value="-1" />
        </customHeaders>
    </httpProtocol>  
</system.webServer>
</location>

This seems to work, however I was wondering if you have any guidance if this is a recommended practice, or is there a better way to prevent the caching of the index.html file?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @JapNolt,

    Actually we don't have any suggestion about this. If in your case, you don't want index.html to be cached, it is good to go like that.