For cache-control to expire in 10 years, is using doc.css?v=128 exactly the same as doc_v128.css?
When using Cache-Control
and Expires
header so that a page won't expire in 10 years:
Cache-Control: max-age=315360000
Expires: Sun, 19 Jul 2020 18:06:32 GMT
will using line 1 have identical result as line 2?
<li开发者_如何学Cnk href="/public/doc.css?v=128" ... >
<link href="/public/doc_v128.css" ... >
I was thinking maybe some browser will take the ?v=128
as a somewhat more dynamic content and reload it before the 10 year expiration?
Otherwise, both files will expire in 10 years and when there is changes to the CSS, the 128
can be updated to 129 and it will be loaded for sure and have a brand new 10 year expiration date?
(the same goes for javascript .js
files)
Using a changing value in the querystring may work against you. According to Google's Page Speed Optimize caching Performance Best Practice:
Don't include a query string in the URL for static resources
Most proxies, most notably Squid up through version 3.0, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for these resources, remove query strings from references to static resources, and instead encode the parameters into the file names themselves.
Also, you may want to reconsider 10 years. According to the Header Field Definitions > Expires section of RFC 2616, one year is the max.
To mark a response as "never expires," an origin server sends an Expires date approximately one year from the time the response is sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.
精彩评论