0

I'm developing a web application, server with ASP.NET and frontend in AngularJS, and every time that I'm deploying a new version, on Azure App Service (IIS as a service) I have a caching problem - the view does not update to the new version until I power on the Disable cache checkbox in the chrome developer tools or press Ctrl+Shift+R

I try to add in the index.html this meta-tags

<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

but it doesn't work. I tried a lot of ideas that I found on the network but the issue doesn't solved

Netanel Stern
  • 149
  • 3
  • 16

2 Answers2

0

I think this has been asked before (or simmilar), source : Disabling browser caching for all browsers from ASP.NET

A solution from this thread which I have found to work for me is to add this to your page header:

<script language="javascript" type="text/javascript">
    window.onbeforeunload = function () {   
    // This function does nothing.  It won't spawn a confirmation dialog   
    // But it will ensure that the page is not cached by the browser.
}  
jasttim
  • 723
  • 8
  • 19
0

There is an IIS configuration for static content to set the cache mode and expiry:

<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="UseExpires"
            httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
      </staticContent>
   </system.webServer>
</configuration>

Then, if you will check requests to the server to get JS and HTML files, will appear few headers:

Response:

  • ETag key for cache entry
  • Last-Modified last modified date of this file

Request:

  • If-Modified-Since last modified date of this file - bring the file from the server if the file's last modified date is different from the specified
  • If-None-Match ETag of cache key - if the last modified date does not differ from the specified, bring file from this cache key
Netanel Stern
  • 149
  • 3
  • 16