我正在浏览我最喜欢的网站的 html...咳咳...我在标记中看到了这个:
<link href="/Content/all.min.css?d=20090107" rel="stylesheet" type="text/css" />
“?d=20090107”是做什么的?我假设它是某种日期,但我不确定为什么它在文件路径中。有什么想法吗?
最佳答案
那是为了给文件名添加一些唯一性,这样当他们更改 CSS 文件时,他们可以更改额外的位以完全确保每个客户端都将重新加载 CSS 而不是使用缓存版本。
网络服务器将忽略该参数并正常提供/Content/all.min.css
注意:虽然 可能 CSS 是动态生成的,但这是确保重新加载的常用习惯用法,并且给定参数是日期,这似乎很有可能。
编辑:Podcast 38提到这个...
We’ve been using the Expires or Cache-Control Header since we launched. This saves the browser round-trips when getting infrequently changing items, such as images, javascript, or css. The downside is that, when you do actually change these files, you have to remember to change the filenames. A part of our build process now “tags” these files with a version number so we no longer have to remember to do this manually.
关于css - '?' 在 Css 链接中有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/438821/