如何在页面刷新时清除当前浏览器会话内存
我一直在使用 OpenLayers 构建一个主要基于 javascript 的大型地图系统,并且通过在处理完数据后清空 ajax json 返回,将我们最大客户帐户上的数据初始页面负载从 400 MB 减少到大约 150 - 180 MB删除不必要的 html。在初始页面加载时,我的浏览器中的内存监视器显示的数字约为 150。当我使用该网站时,它会增加一点,这是预期的。但是,如果我刷新页面,浏览器会占用一堆以前的内存,然后在刷新加载完成时几乎翻倍。
我已将 onunload="map = null" 添加到我们的映射库中,其中“map”是 javascript var。我已将 php 行添加到标题中:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
我已将元行添加到标题中:
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Expires" content="-1">
但我仍然无法摆脱常驻内存。当我第一次启动浏览器时,加载空白页面时大约使用 35MB。我预计如果我刷新页面,浏览器应该转储该页面的内存(给出上面的行)并从 35MB 标记重新开始。
有人能解决这个恼人的问题吗?
谢谢!
I have been building a large mostly javascript based mapping system using OpenLayers and I have slimmed the initial page load of data on our largest client account down from 400 MB to about 150 - 180 MB by nulling out ajax json returns when done with the data and removing unnecessary html. On the initial page load, the memory monitor in my browser shows a good number down around 150. As I use the site it builds up a bit, which is expected. BUT, if I refresh the page, the browser clings to a bunch of the previous memory and then nearly doubles by the time the refresh is done loading.
I have added onunload="map = null" where "map" is a javascript var to our mapping library. I've added the php lines as such to the header:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
I've added the meta lines to the header:
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Expires" content="-1">
But I still can't get rid of the resident memory. When I first launch the browser it's using 35MB roughly on loading the blank page. I would have expected that if I refresh the page, the browser should dump the memory of that page (given the lines above) and start over from the 35MB mark.
Does anyone have a solution to this irritating problem?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论