[英]css and js files are being cached by the iframe
I am using a jquery plugin named facebox. 我正在使用一个名为facebox的jquery插件。 It works very well but I am faced!
它工作得很好,但我面临着! with an issue.
有问题。 It looks like its iframe method is causing my browser to cach the css that is being loaded in the target page.
看来,它的iframe方法正在导致我的浏览器缓存目标页面中正在加载的CSS。
This is how I call it in my page in the jquery ready state. 这就是我在jquery ready状态下在页面中调用它的方式。
$('a.participate').click( function(){
$.facebox({
iframe: '" . $urlparticipate . "',
rev: 'iframe|550|550'
});
return false ;
});
where $urlparticipate is the url that will open in the iframe. 其中$ urlparticipate是将在iframe中打开的网址。 I looked closer in the facebox.js and I found the following method that seems to be used by the plugin to create the iframe.
我在facebox.js中仔细观察,发现插件似乎使用了以下方法来创建iframe。
function fillFaceboxFromIframe(href, klass, height, width) {
$.facebox.reveal('<iframe scrolling="auto" marginwidth="0" width="'+width+'" height="' + height + '" frameborder="0" src="' + href + '" marginheight="0"></iframe>', klass)
}
How can I prevent the css from being cached? 如何防止CSS缓存? I know that is being cached because I change the css style of an element.
我知道正在缓存,因为我更改了元素的CSS样式。 I even changed some js code that is being loaded and its still loading the old one.
我什至更改了一些正在加载的js代码,并且仍在加载旧的js代码。
I also tried the following: 我还尝试了以下方法:
Adding in the target page on the front end in the head 在前端的前端添加目标页面
meta http-equiv="Cache-control" content="no-cache" meta http-equiv =“ Cache-control” content =“ no-cache”
meta http-equiv="Pragma" content="no-cache" meta http-equiv =“ Pragma” content =“ no-cache”
meta http-equiv="Expires" content="0" meta http-equiv =“ Expires” content =“ 0”
I tried to add some headers from code behind (php) 我试图从(php)后面的代码中添加一些标头
header("Cache-Control: no-cache"); header(“ Cache-Control:no-cache”);
header("Pragma: no-cache"); header(“ Pragma:no-cache”);
All with no success.. What am I missing? 一切都没有成功..我想念什么?
You can always try "versioning" the CSS reference on the page. 您始终可以尝试在页面上“版本化” CSS参考。 There are good and not-so-good ways to do it: With a single, static version number you append every time you make a change, or a randomly generated GUID that will effectively force EVERY request to the page to retrieve the CSS file(s).
有好方法,也有不太好方法:每次更改时都使用一个静态的版本号附加,或者使用随机生成的GUID有效地迫使每个请求都检索到CSS文件( S)。 The better option is the static one, like this:
更好的选择是静态选择,如下所示:
<link type="text/css" rel="stylesheet" href="cssfile.css?1.12" />
Try throwing a var with the CSS filename (typically the version number) so the browser can't cache it. 尝试使用CSS文件名(通常是版本号)引发var,以便浏览器无法对其进行缓存。 Something like foo.css?ver=bar
像foo.css?ver = bar这样的东西
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.