web.config中没有IIS Internet Information Server缓存设置



我正在使用IIS开发Azure服务;但是,我无法使web.config在没有缓存的情况下工作。如何在没有缓存的情况下更改它并覆盖所有js脚本?

如果我理解正确,您正在询问如何在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://learn.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache

相关内容

最新更新