web.config中對應的配置以下:web
<configuration>
<system.webServer>
<caching>
<profiles>
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
</profiles>
</caching>
</system.webServer>
</configuration>
瀏覽器中看到的效果:
瀏覽器
解決方法:緩存
一、禁用User-mode caching,只用Kernel-mode caching。
服務器
二、在web.config中加上cacheControlCustom="public"spa
<configuration> <system.webServer> <staticContent> <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="300.00:00:00" /> </staticContent> <caching> <profiles> <add extension=".css" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="30:00:30" /> <add extension=".js" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="30:00:30" /> </profiles> </caching> </system.webServer> </configuration>