为什么/何时需要在浏览器中努力刷新网页?
背景
虽然有许多博客,但 如何找到为什么/ 时!而且大多数人都知道为什么,但不是所有人。
方案
- 您一直在同一网站上。
- 您是测试人员,您的开发团队已发布了Web应用程序的新版本。
- 您是企业家,并且已发布了Web应用程序的新版本。 Web URL中,您正在加载以下内容之一:
- Web应用程序根本不会加载。
- Web应用程序突然开始表现不一致。
- 加载页面时的新随机错误发生。
类比
虽然上面提到的这些问题的背后有很多原因,例如软件中的错误,或浏览器与新组件等不兼容。最快的决议是:“硬页面刷新” !
但为什么? (见下文)
Background
While there are many blogs, stackoverflow questions and answers on the HOW I have not found a single trace of the WHY/WHEN! And fair enough most people do know about the why but NOT all people.
Scenarios
- You have been going to the same site.
- You are a tester and your development team has release a new version of the web app.
- You are an entrepreneur and you have release a new version of your web app.
And one of the following is happening to web url you are loading on your browser: - The web app does not load at all.
- The web app starts behaving inconsistently all of a sudden.
- New random bugs in loading the page occurs.
Analogy
While there maybe a lot of reasons behind these issues mentioned above such as a bug in the software, or browser incompatibility with a new component, etc. Before you go and do all the relevant actions to debug or resolve those one of the easiest and fastest resolutions is to: "HARD PAGE REFRESH"!
But why? (See below)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
我希望这对你有帮助
i hope this help you
简短的答案
浏览器缓存CSS,JS和其他文件,以改善Web应用程序的加载时间及其相关页面。取决于添加JS,CSS的新版本时如何实现网站,并与文件的旧版本相差。页面的新部分是调用或与浏览器中缓存的文件的旧版本进行交互。这导致行为不一致。
很长的答案
在Web应用程序开发的过去, ,页面有较小的JavaScript和CSS文件,如果有足够的冷却,可以超越基本的HTML页面。还存储在单独的HTML文件中的页面。单击新链接时,浏览器将加载一个全新的页面应用程序。
在现代Web应用程序中,转向单页应用程序。这些是您拥有负责在内容上加载的单页的应用程序。使用新技术构建了所有现代网站(例如Facebook,Netflix等)。
在单页应用程序中,同一页面上附带了大的JS和CSS文件。这意味着,尽管我们的互联网速度有所改善,但每次用户进行刷新时,浏览器都会加载整个单页及其所有JS,CSS,IMG文件的效率低下。通过缓存这些文件,这意味着浏览器现在只需要在页面上加载新的数据内容。这会带来更好的用户体验。
不利的一面是发布新的JS或CSS文件,并且浏览器仍在使用旧的JS或CSS文件。它将以不可预测的方式影响业务逻辑或布局。这就是为什么浏览器引入了硬页面刷新选项,以允许从后端服务器而不是缓存加载单页应用程序的加载。
如果此主题感兴趣,您可以在最佳练习中进行有关如何设置单页应用程序的最佳练习缓存的资产。
有用的链接,
根据读者的请求,我提供了以下一些良好的读物。
Short Answer
Browsers cache CSS, JS and other files to improve the loading time of web applications and their relevant pages. Depending on how the website is implemented when a new version of the JS, CSS is added and difference in a shape and form with the old version of the file. New part of the page are calling or interacting with an old version of the file that is cached in the browser. This results in the inconsistent behaviour.
Long Answer
In old days of web applications development, pages had smaller JavaScript and CSS files if there where cool enough to go beyond the basic HTML pages. Also pages stored in separate HTML files. And the browser would load a whole new page application as you clicked on a new link.
In modern web applications the shift was towards Single Page Applications. These are applications where you have a single page that is responsible for loading on the content. All modern websites (e.g. Facebook, Netflix, etc.) have been built using the new technique.
In Single Page Applications, the same page has large JS and CSS files attached to it. That means despite the massive improvement to our internet speed, it will be in inefficient for the browser to load the whole Single Page and all its JS, CSS, IMG files every time the user does a refresh. By caching these files that means the browser now only needs to load new data content on the page. This results in far better user experience.
The downside of this was when a new JS or CSS file was released and the browser was still using the old JS or CSS file. It would impact the business logic or the layout in unpredictable ways. That why browsers introduced a HARD PAGE REFRESH option to allow the load of a single page application be forced to load from the backend server rather than the cache.
If this topic interests you you can do further read on best practice on how to setup your single page application to ensure every time you release a new JS or CSS or even images it is guaranteed that the browsers reload the content and don't use the cached assets.
Useful links
I have provided some good reads below as per on of the reader's requests.