简体   繁体   English

如何防止浏览器加载旧源

[英]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.

相关问题 如何防止浏览器按范围从内存缓存中加载js? - How to prevent browser from loading js from memory cache by range? 如何配置cloudfoundry静态文件buildpack以防止发布后从浏览器缓存加载 - How to configure cloudfoundry staticfile buildpack to prevent loading from browser cache after a release 如何防止浏览器缓存视频? - How to prevent a browser from caching videos? 如何防止浏览器存储Blob? - How to prevent browser from storing Blobs? 如何防止浏览器缓存json文件 - How to prevent the browser from caching a json file 如何以编程方式从浏览器的缓存中删除旧的applet? - how to remove old applet from browser's cache programmatically? 从应用程序注销后,如何防止在单击浏览器的后退按钮时加载Dashboard? - How can prevent loading Dashboard on clicking browser's back button after login out of the application? 如何防止用户的浏览器显示页面的缓存版本? - How to prevent user's browser from showing cached version of a page? ReactJS:如何防止浏览器缓存静态文件? - ReactJS: How to prevent browser from caching static files? 如何阻止浏览器显示页面的缓存版本? - How do you prevent the browser from displaying a cached version of a page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM