3
我想为我的js,css和html文件设置不同的缓存控制头文件值。 我知道有关基于每个文件夹设置它的选项,但我的应用程序在同一个文件夹中包含html和js文件。IIS - 为每个文件类型设置缓存控制头文件
它甚至可能在IIS中?
我想为我的js,css和html文件设置不同的缓存控制头文件值。 我知道有关基于每个文件夹设置它的选项,但我的应用程序在同一个文件夹中包含html和js文件。IIS - 为每个文件类型设置缓存控制头文件
它甚至可能在IIS中?
这在使用IIS出站重写规则的IIS 7+中是可能的。例如。如果要使所有.html页无效,请在web.config的outboundRules部分中创建以下出站规则(安装IIS重写模块后):
<outboundRules>
<rule name="AdjustCacheForHTMLPages" preCondition="IsHTMLFile">
<match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
<action type="Rewrite" value="no-cache, no-store, must-revalidate" />
</rule>
<preConditions>
<preCondition name="IsHTMLFile">
<add input="{REQUEST_FILENAME}" pattern=".*\.html" />
</preCondition>
</preConditions>
</outboundRules>