【问题标题】:how to add Expires headers to asp.net without changing settings in IIS manager如何在不更改 IIS 管理器中的设置的情况下将 Expires 标头添加到 asp.net
【发布时间】:2014-02-08 14:28:47
【问题描述】:

当我在我的页面上使用 Y SLOW 工具时。它在添加到期标题上显示 D 级。它显示了一些没有过期标题的图像和 css 文件。如何向它们添加到期标头。我无法更改 IIS 管理器上的设置。有没有其他办法。我还在web.config 文件中添加了以下几行。

<staticContent>
     <clientCache cacheControlCustom="" cacheControlMode="UseExpires" httpExpires="Thu, 31 Dec 2020 00:00:00 GMT"></clientCache>
</staticContent>

但仍然没有用。还有其他解决方案吗?

【问题讨论】:

  • 不是这个问题的答案,但您可以通过在文件名末尾添加 ?v=1.0.x 来版本化 css 和图像,这可能对您有用 - 但绝不这个问题的答案;只是想分享。

标签: c# asp.net css yslow


【解决方案1】:

你可以使用 Response.AddHeader

Response.AddHeader("Expires", "Thu, 01 Dec 2014 16:00:00 GMT")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多