如何指定HTTP过期标头? (ASP.NET MVC + IIS) [英] How to specify HTTP expiration header? (ASP.NET MVC+IIS)

查看:110
本文介绍了如何指定HTTP过期标头? (ASP.NET MVC + IIS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用输出缓存在我的ASP.NET MVC应用程序。

I am already using output caching in my ASP.NET MVC application.

网页速度告诉我指定的CSS和图像在响应头HTTP缓存过期

Page speed tells me to specify HTTP cache expiration for css and images in the response header.

我知道Response对象包含一些属性控制缓存过期。我知道,这些属性可以用来控制HTTP缓存响应,我的从我的code服务:

I know that the Response object contains some properties that control cache expiration. I know that these properties can be used to control HTTP caching for response that I am serving from my code:

Response.Expires
Response.ExpiresAbsolute
Response.CacheControl

或备选

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

问题为如何设置为自动服务资源,例如Expires头图片,CSS等?

推荐答案

发现:

我需要指定静态内容(在web.config中)客户端缓存。

I need to specify client cache for static content (in web.config).

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlCustom="public" 
      cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>
   </system.webServer>
</configuration>

从<一个href=\"http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache\">http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache

这篇关于如何指定HTTP过期标头? (ASP.NET MVC + IIS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆