0

I am working on Azure Service with IIS; however, I cannot make the web.config works with no-cache. How can I change it for no-cache and overwrite all js scripts?

  • You can configure no-cache in web.config: . This has a similar problem you can refer to it: https://stackoverflow.com/questions/26600845/how-to-disable-caching-of-single-page-application-html-file-served-through-iis – Ding Peng Jan 06 '21 at 05:04

1 Answers1

0

If I understand correctly, you are asking how to disable the cache IIS cache in JS

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site";

var staticContentSection = adminManager.GetAdminSection("system.webServer/staticContent", "MACHINE/WEBROOT/APPHOST/Default Web Site");
var clientCacheElement = staticContentSection.ChildElements.Item("clientCache");
clientCacheElement.Properties.Item("cacheControlMode").Value = "DisableCache";

adminManager.CommitChanges();

Or via web.config to disable caching of requests:

<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="DisableCache" />
      </staticContent>
   </system.webServer>
</configuration>

Ref: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache

wp78de
  • 16,078
  • 6
  • 34
  • 56