简体   繁体   English

HTML javascript链接在HTML 5 Boilerplate中包含url变量

[英]Html javascript links include url variables in HTML 5 Boilerplate

When I was looking at HTML 5 Boilerplate I noticed one thing: Almost every script link goes like this : '../script.js?v=1' . 当我查看HTML 5 Boilerplate时,发现了一件事:几乎每个脚本链接都像这样: '../script.js?v=1' This 'v=1' part caught my attention so I did some research and found out that it is there for cache-ing purposes. “ v = 1”这一部分引起了我的注意,因此我进行了一些研究,发现它在那里用于缓存。 My question is : How is this technique called and how is it done? 我的问题是: 该技术如何调用以及如何完成? Is there a way to change/ update version numbers automatically? 有没有一种方法可以自动更改/更新版本号?

This is usually called a cachebusting URL. 这通常称为缓存无效化URL。

If you change script.js , you can simply change it to ?v=2 to force the browser to skip the cache. 如果更改script.js ,则只需将其更改为?v=2即可强制浏览器跳过缓存。 (because there is not cached content for script.js?v-2 ) (因为没有script.js?v-2缓存内容)

Most server-side web environments have plugins that can automatically generate cache-busting URLs, usually by including a hash of the file in the querystring. 大多数服务器端Web环境都具有可自动生成缓存清除URL的插件,通常通过在查询字符串中包含文件的哈希值来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM