小编Ala*_*lan的帖子

如何将<clientCache />设置应用于IIS中的特定扩展?

我在Azure上使用以下Web.config托管Web应用程序:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".text" mimeType="text/plain" />
      <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
    </staticContent>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这有效,但我想通过扩展来改变缓存时间.我想将.html文件的最大年龄设置为1天,将其他所有文件的最大年龄设置为365天.原因是html中的所有资产都有其文件名在更改时加速并且是从CDN提供的,因此它们永远不需要过期,但是html页面本身需要始终保持新鲜,以便用户可以看到新内容.

我看到该<location>元素允许将Web.config过滤到特定位置,但我没有看到将其限制为某些扩展的方法.

请注意,我不要求能够做到这一点在Web.config:任何可能的手段与Azure的Web应用程序的罚款.

iis web-config azure azure-web-sites

10
推荐指数
1
解决办法
2081
查看次数

标签 统计

azure ×1

azure-web-sites ×1

iis ×1

web-config ×1