实现页面定时刷新但不出现页面闪烁
他们是如何实现这一目标的?
I cannot understand how Bing Community site is implemented. Clicking one of the "All Recent" "Unanswered" "Unread" or "Your Discussions" issues regulare request that refreshes whole page (proxy display regular request) also it changes URL (full URL not just #hash). But page does not flash!
How they achieved this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我来说,它在 FF3 上不闪烁,但在 IE6 上闪烁。 所以,我认为这与浏览器的渲染有更多关系。
顺便说一句,查看页面是否完全重新加载的快速测试(大多数情况下有效)是选择一些文本(我选择了 bing.com 上的顶部导航文本)——如果页面重新加载,您的选择将是丢失的。
For me, it doesn't flash on FF3, but it does flash on IE6. So, I think it has more to do with the browser's rendering.
BTW, a quick test (which works most of the time) to see if a page is fully being reloaded is to select some text (I selected the top navigation text on bing.com) -- if the page reloads, your selection will be lost.
他们肯定会进行整页刷新。 Firebug 的 Net 面板和 Firefox 的 Live HTTP Headers 插件都显示正在请求的新页面,就像通过 Charles 等代理监视请求一样。
然而,根据 Y!Slow 的说法,整个操作只需要不到一秒钟。 他们发回大约 9k 压缩后的 HTML,而其他所有内容(他们的精灵、脚本等)都从缓存中提取。 我想您已经看到了在浏览器中发送回带有缓存资源的轻量压缩页面的速度有多快。 Bing 在优化其网站的这方面方面做得非常出色,以实现非常快的页面加载。
They're definitely doing a full-page refresh. Firebug's Net panel and Firefox's Live HTTP Headers plugin both show a new page being requested as does monitoring the request via a proxy like Charles.
However, according to Y!Slow, the entire operation takes less than a second. They're sending back about 9k of HTML gzipped, and everything else (their sprites, scripts, etc.) is pulled out of the cache. I think you're seeing how fast sending back a really light, gzipped page with cached assets renders in the browser. Bing's done a great job of optimizing this aspect of their site for very fast page loads.
不确定 URL 是否是这样更改的,但您可以轻松地请求新页面并使用 AJAX 更改页面内容。 我想就是这样。
Not sure if this is how the URL gets changed, but you can easily request the new page and change the page contents using AJAX. I'm assuming that's how.