获取相关js文件:添加 ?t=B48E5AB 有什么意义
我使用的是 CKEditor,它是一个多文件库,因此主 js 文件调用其他 js 和 css 文件。我注意到在调用主文件后,其他文件中添加了 ?t=CODE
,所以类似这样,但实际文件没有额外的 ? t=B49E5BQ 位于末尾。
http://site.com/ckeditor/config.js?t=B49E5BQ
http://site.com/ckeditor/extra.js?t=B49E5BQ
的意义何在?
这个P.S 请随意添加其他标签,因为我不确定这个标签。
I'm using CKEditor which is a multi-file library so the main js file calls other js and css files. I'm noticing that after the main file is called, additional files have a ?t=CODE
added to them, so something like this, but the actual files don't have that extra ?t=B49E5BQ
at the end.
http://site.com/ckeditor/config.js?t=B49E5BQ
http://site.com/ckeditor/extra.js?t=B49E5BQ
What's the point of this
P.S. Please feel free to add additional tags, because I'm not sure about this one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我偶尔会对图像和脚本文件执行此操作。就我而言,这是一个毫无意义的参数(通常是日期时间),只会强制浏览器每次都获取新副本。
如果参数不断变化,这些文件将不会缓存在客户端。
I do this occasionally for images and script files. In my case, it's a meaningless argument (usually datetime) that just forces the browser to fetch a new copy every time.
If the parameter keeps changing, those files won't be cached on the client side.
通常这比说的更容易,更改文件名以包含版本号(
jquery-1.6.2.js
效果很好,但是您想重命名config.js 更改为
config-1.0.js
、-2.0
等?像所有其他答案一样,这只是强制浏览器获取最新版本查询字符串 (
?t=B49E5BQ
) 更改时的版本在我们的示例中,我们只需添加日期 (?06022011
)。Often this is easier than say, changing the name of the file to include a version number (
jquery-1.6.2.js
works nicely, but do you want to renameconfig.js
toconfig-1.0.js
,-2.0
, etc. every time you make a change?Like all the other answers, this simply forces the browser to grab the latest version when the querystring (
?t=B49E5BQ
) is changed. In our case, we simply add the date (?06022011
).此类尾随数据有时会放入脚本/样式表等资源文件的 URL 中,以防止重新部署时缓存资源。
每当您更改资源时,您都会更改需要该资源的 HTML 文件/模板中的代码,以便客户端在下次加载页面时重新从服务器请求资源。
This sort of trailing data is sometimes put into URLs for resources files like scripts/stylesheets so as to prevent caching of resources across re-deployments.
Whenever you change a resource, you change the code in HTML files/templates which require that resource, so that clients re-request the resource from the server the next time they load the page.
我猜测添加 URL 参数是为了绕过任何缓存机制。当客户端看到具有不同查询参数的相同 URL 时,通常意味着客户端无法使用资源的缓存版本(在本例中为 JS 文件)并转到服务器获取最新版本。
在 HTTP 中,如果 URL 除了 URL 参数之外在所有方面都相同,则客户端不能假设这些文件/资源是相同的结果对象。
这意味着:
不等于:
I would guess that the URL parameter is added to bypass any caching mechanisms. When a client sees the same URL with a different query parameter, that usually means the client can't use the cached version of the resource (in this case a JS file) and go to the server to fetch the latest version.
In HTTP, if a URL is the same in every way except for the URL parameters, a client can not assume that those files/resources are the same resulting object.
Which means:
is not the same as:
它必须存在于防止缓存。
It must be there to prevent caching.