jQuery的CDN和远距过期标头 [英] jQuery's CDN and Far-Future Expire Headers
问题描述
问题
为什么jQuery的CDN提供的内容缺乏远期的过期标头? (或者,我在这里做错了什么?")
背景
我正在Web项目上使用jQuery和jQuery Mobile.为了提供这些脚本,我使用jQuery的CDN,
感谢您的时间. http://code.jquery.com/jquery-1.6.4. min.js 响应:
https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js 响应: 请注意, 我正在使用Microsoft的CDN托管版本,该版本的有效期为1年: http://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.0/jquery.mobile-1.1.0.min.js @zuul在下面解释了为什么某些CDN托管项目的过期标头比其他标头更长的原因.谢谢! Microsoft还拥有一个CDN,用于托管jquery移动设备: http://www.asp.net/ajaxLibrary/CDNjQueryMobile110.ashx Expire-Date大约是未来一年! Why does content served from jQuery's CDN lack far-future expire headers? (or, "What am I doing wrong here?") I'm using jQuery and jQuery Mobile on a web project. To serve these scripts, I use jQuery's CDN, per their directions. However, I've noticed that these resources are served without far-future expires headers, which prevents browsers from being able to cache them intelligently. Although the jQuery servers will respond with Thanks for your time. http://code.jquery.com/jquery-1.6.4.min.js Response:
https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js Response: Note the far-future expires date in I'm using Microsoft's CDN hosted version which features a 1 year expire date: http://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.0/jquery.mobile-1.1.0.min.js Full list of CDN hosted files. @zuul explained below why some CDN hosted items have longer expire headers than others. Thanks! Microsoft also has a CDN wich is hosting the jquery mobile stuff: http://www.asp.net/ajaxLibrary/CDNjQueryMobile110.ashx Expire-Date is about 1 year in the future! 这篇关于jQuery的CDN和远距过期标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!示例
jQuery CDN
HTTP/1.1 304 Not Modified
Date: Wed, 16 May 2012 00:05:27 GMT
ETag: "9e68e84-16615-6ad9bfc0+gzip"
Last-Modified: Mon, 12 Sep 2011 22:55:03 GMT
Server: ECS (dca/532A)
Vary: Accept-Encoding
X-Cache: HIT
Google CDN
HTTP/1.1 200 OK
age:134505
cache-control:public, max-age=31536000
content-encoding:gzip
content-length:32103
content-type:text/javascript; charset=UTF-8
date:Mon, 14 May 2012 10:45:15 GMT
expires:Tue, 14 May 2013 10:45:15 GMT
last-modified:Mon, 02 Apr 2012 18:24:28 GMT
server:sffe
status:200 OK
vary:Accept-Encoding
version:HTTP/1.1
x-content-type-options:nosniff
x-xss-protection:1; mode=block
expires:Tue, 14 May 2013 10:45:15 GMT
解决方案
Question
Background
304 Not Modified
, that's not the same as an expire header the negates that request altogether. I realize the simple answer here is "because they don't" however, I'm wondering why they don't, and if there's some way I can serve this content, ideally from a CDN, with far-future expires headers.Examples
jQuery CDN
HTTP/1.1 304 Not Modified
Date: Wed, 16 May 2012 00:05:27 GMT
ETag: "9e68e84-16615-6ad9bfc0+gzip"
Last-Modified: Mon, 12 Sep 2011 22:55:03 GMT
Server: ECS (dca/532A)
Vary: Accept-Encoding
X-Cache: HIT
Google CDN
HTTP/1.1 200 OK
age:134505
cache-control:public, max-age=31536000
content-encoding:gzip
content-length:32103
content-type:text/javascript; charset=UTF-8
date:Mon, 14 May 2012 10:45:15 GMT
expires:Tue, 14 May 2013 10:45:15 GMT
last-modified:Mon, 02 Apr 2012 18:24:28 GMT
server:sffe
status:200 OK
vary:Accept-Encoding
version:HTTP/1.1
x-content-type-options:nosniff
x-xss-protection:1; mode=block
expires:Tue, 14 May 2013 10:45:15 GMT
Solution