javascript - 在哪些浏览器中查询字符串(以防止缓存)有效?

标签 javascript html css

我想将查询字符串“?v=123”附加到所有 .css 和 .js 文件,以强制客户端浏览器在新部署后下载样式表或脚本的更新副本。

这是否适用于所有浏览器? 对我来说,在 IE8、IE9、IE10、IE11、FireFox 和 Chrome 中工作很重要。

但是如果这在所有浏览器中都有效,我找不到信息。 如果有人有经验,请与我分享。

最佳答案

是的。

它是一个查询字符串参数,已成为specification 的一部分。自 1994 年以来:

An HTTP URL takes the form:

http://<host>:<port>/<path>?<searchpart>

where and are as described in Section 3.1. If : is omitted, the port defaults to 80. No user name or password is allowed. is an HTTP selector, and is a query string. The is optional, as is the and its preceding "?". If neither nor is present, the "/" may also be omitted.

关于javascript - 在哪些浏览器中查询字符串(以防止缓存)有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25398515/

相关文章:

css - 如何底部对齐 bootstrap 4 中的按钮?

html - 当容器具有翻译 css 时,Fieldset 图例被击中

javascript - 如何在javascript中设置文件路径?

javascript - HTML <select> 元素发送默认选择,即使未选择

html - 来自 CSS 文件的 404

html - 与 Chrome 相比,Flexbox 在 Safari 上的工作方式不同

javascript - 如何确定 elements.parentNode 或 Ancestor 是否有类?

javascript - 多个选择器上的 jQuery on() 方法

jquery - 如何改变JQuery对话框的位置

css - 滚动时移动重叠的滑动垂直图像