HTTP头到期在web.config中asp.net [英] http expire headers in asp.net with web.config

查看:225
本文介绍了HTTP头到期在web.config中asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让YSlow的给我上的A通过设置web.config文件添加Expires头部分。

I'm trying to get YSlow to give me an A on the "Add Expires header" section by setting the web.config file.

我一直在四处寻找,这就是我把基于什么时候会再有:

I've been looking around and this is what I put in based on what's out there:

<staticContent>
    <clientCache httpExpires="15.00:00:00" cacheControlMode="UseExpires"/>
    </staticContent>
</system.webServer>

这是我所看到的萤火虫:

This is what I'm seeing in Firebug:

Response Headers

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Sun, 28 Aug 2011 13:54:50 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: image/jpeg
Content-Length: 24255
Connection: Close


Request Headersview source
Host    localhost:50715
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0
Accept  image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive
Referer http://localhost:50715/MySite/SiteHome.html
Pragma  no-cache
Cache-Control   no-cache

然而,当我看着它在Firefox,YSlow的仍然是这个给人一个F,甚至经过键Crtl-F5

However, when I look at it in Firefox, Yslow is still giving an F on this, even after a Crtl-F5

我是什么失踪?

感谢。

推荐答案

文档clientCache

对于httpExpires属性的值必须遵循在RFC 1123的规范,例如一个完全格式化的日期和时间:
  周五,2010 01一月12:00:00 GMT

The value for the httpExpires attribute must be a fully-formatted date and time that follows the specification in RFC 1123. For example: Fri, 01 Jan 2010 12:00:00 GMT

所以,如果你想使用HTTP过期头为你的静态内容,将其设置是这样的:

So, if you want to use the http expires headers for your static content, set it like this:

<staticContent>
  <clientCache cacheControlMode="UseExpires" httpExpires="Sun, 1 Jan 2017 00:00:00 UTC" />
</staticContent>

更新(适用于上述评论):这将很可能仍然没有工作,内置的VS服务器。我不知道它是否支持在所有到期头。据我所知,这是一个IIS设置。

Update (to above comments): This will most probably still not work in the built in VS server. I'm not sure if it supports expires headers at all. AFAIK this is an IIS setting.

这篇关于HTTP头到期在web.config中asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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