[英]How to prevent browser from loading the old source
Edit : I don't know if it actually loads from cache , so I can't create the question named "prevent from loading cache". 编辑: 我不知道它是否实际上从缓存加载 ,所以我不能创建名为“防止加载缓存”的问题。
Problem : Browsers sometimes save my code and keep loading only the code they saved(Maybe it saves in the cache). 问题 :浏览器有时会保存我的代码,并仅加载他们保存的代码(也许保存在缓存中)。 When this problem occurs, browser is like caching the old code and won't change anything.
发生此问题时,浏览器就像在缓存旧代码,不会进行任何更改。 This is to say, It won't load any new code I updated.
就是说,它不会加载我更新的任何新代码。
Information : This occurs in HTML, CSS, Javascript on all browsers. 信息 :这在所有浏览器中都以HTML,CSS,Javascript出现。 I am using Apache in XAMPP as an appserv.
我在XAMPP中将Apache用作appserv。
Deleting cache in all browsers won't fix this. 在所有浏览器中删除缓存将无法解决此问题。
My first way to stop this is to delete the file, refresh browser and replace it. 停止此操作的第一种方法是删除文件,刷新浏览器并替换它。 The second ways is changing the pathname.
第二种方法是更改路径名。
After the fix, the problem will occur again at anytime :(, so I would like to know how to prevent this. 修复之后,问题随时会再次发生:( ,,所以我想知道如何防止这种情况。
Edited: If possible, please explain for newbie because I am very young beginner. 编辑:如果可能的话,请为新手解释,因为我还很年轻。
尝试在其查询字符串中的每个网址中添加一个像当前时间戳这样的变量。
Just use querystring eg http://www.domain.com/style.css?version=1
for first version. 只需使用querystring
eg http://www.domain.com/style.css?version=1
第一个版本的eg http://www.domain.com/style.css?version=1
。
Now you update the stylesheet and you would like to reflact changes to all users browser who have cached version of old stylesheet. 现在,您更新样式表,并希望将所做的更改反映给已缓存旧样式表版本的所有用户浏览器。 for this just change version querystring value to 1.1
为此,只需将版本querystring值更改为1.1
e.g. http://www.domain.com/style.css?version=1.1
This works for javascript, css and all other files called in by your html page. 这适用于javascript,css和html页面调用的所有其他文件。
Also for all files like html, css, js, you can eTag header. 同样对于所有文件,例如html,css,js,您都可以使用eTag标头。 More information can be found here.
更多信息可以在这里找到。
http://www.w3.org/2005/MWI/BPWG/techs/CachingWithETag.html http://www.w3.org/2005/MWI/BPWG/techs/CachingWithETag.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.