IIS Internet Information Server no-cache setting in web.config

1.3k views Asked by At

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?

1

There are 1 answers

0
wp78de On

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://learn.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache