[英]How to prevent page from caching in Firefox using Greasemonkey script
我需要编写一个Greasemonkey脚本,以防止Firefox缓存某些页面。 那有可能吗?
我知道可以重新加载页面
window.location.reload(true)
-但是当从缓存中加载页面时,脚本甚至无法运行,即使脚本运行,我如何知道该页面是从缓存而非URL加载的呢?
我知道
<meta http-equiv="Cache-control" content="No-Cache">
页面的HTML可以解决问题,但是只能在初始加载时进行解析,并且无法通过GM添加它...
那么,我该如何实现呢? 通用汽车有可能吗?
您不能阻止页面被缓存,但是您可能能够做第二件好事并添加一个缓存破坏器。
http://www.adopsinsider.com/ad-ops-basics/what-is-a-cache-buster-and-how-does-it-work/
function() {
// var url = window.location.href;
var url = "http://z.invalid?cachebuster=10";
var bits = url.split('?');
var newUrl = bits[0];
newUrl += "?cachebuster=" + Math.random()*10000000000000000;
window.location.href = newUrl;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.