0

我正在使用 IIS 开发 Azure 服务;但是,我无法使 web.config 与无缓存一起使用。如何将其更改为无缓存并覆盖所有 js 脚本?

4

1 回答 1

0

如果我理解正确,您是在问如何在 JS 中禁用缓存 IIS 缓存

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();

或通过 web.config 禁用请求缓存:

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

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

于 2021-01-05T18:59:22.257 回答