admin管理员组文章数量:1291050
I'm trying to cache some documents client-side in order to switch between them faster.
The documents have been loaded in an iframe, so it's a question on how to cache it locally within the browser.
My method was to have a variable, item, and then do
if (item.cache) {
$('.holder', someElem).html(item.cache);
return;
}
item.cache = $('<iframe....');
$('.holder', someElem).html(item.cache);
However, this method keeps reloading the iframe src, when injected on to the holder.
Any good methods for client-side iframe caching?
I'm trying to cache some documents client-side in order to switch between them faster.
The documents have been loaded in an iframe, so it's a question on how to cache it locally within the browser.
My method was to have a variable, item, and then do
if (item.cache) {
$('.holder', someElem).html(item.cache);
return;
}
item.cache = $('<iframe....');
$('.holder', someElem).html(item.cache);
However, this method keeps reloading the iframe src, when injected on to the holder.
Any good methods for client-side iframe caching?
Share Improve this question asked Jan 24, 2011 at 15:56 freeallfreeall 3,1984 gold badges26 silver badges31 bronze badges 1- If you want the opposite- do not cache iframe- see Refresh iFrame (Cache Issue) – Michael Freidgeim Commented Jun 3, 2021 at 2:41
2 Answers
Reset to default 4The iframe
doesn't actually trigger a page refresh until it has been added to the dom
. I am guessing you keep an instance of the iframe
but not add it to the dom until its time to see it. This method doesn't work well. I would suggest using css "display:none" to load it and hide and then show it when you need it.
HTTP has caching built in. Mark Nottingham has written a decent overview. Setting the Cache-Control
and Expires
headers should be enough for what you describe.
本文标签: javascriptA good method for clientside iframe cachingStack Overflow
版权声明:本文标题:javascript - A good method for client-side iframe caching - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741511258a2382620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论