admin管理员组文章数量:1315287
i have a iframe and it takes a while for for the content to e back. I can't avoid using the iframe, so i'm wondering if i can somehow:
- cache the content, so that when i revisit the page, it loads very fast.
- prefetch the page that has the iframe on it. Here I've tried using
<link rel="prefetch" href="..." />
, but it seems that it has no effect on the iframe
any ideas how to solve this issue? Can be a front end or a back end solution?
i have a iframe and it takes a while for for the content to e back. I can't avoid using the iframe, so i'm wondering if i can somehow:
- cache the content, so that when i revisit the page, it loads very fast.
- prefetch the page that has the iframe on it. Here I've tried using
<link rel="prefetch" href="..." />
, but it seems that it has no effect on the iframe
any ideas how to solve this issue? Can be a front end or a back end solution?
Share Improve this question edited Jun 20, 2013 at 20:48 Nathan Hughes 96.5k20 gold badges191 silver badges284 bronze badges asked Jun 20, 2013 at 19:39 PatrioticcowPatrioticcow 27.1k76 gold badges221 silver badges339 bronze badges 4-
You could load the iframe but set
display: none;
until it's required. – Joe Commented Jun 20, 2013 at 19:49 - @Joe. im not sure you get my point. I want the content cached or prefetch – Patrioticcow Commented Jun 20, 2013 at 20:04
- I understand your point but it's not possible to prefetch the iframe content without loading it hidden and then displaying it. The user's browser caching the iframe content depends on the iframe site's cache headers. You could always fetch the remote site in PHP then serve it from your server in an iframe. However, this won't work if the remote content is dynamic. – Joe Commented Jun 20, 2013 at 20:08
-
@Joe i have
age1.html
that has a link topage2.html
.page2.html
has theiframe
on it. How can i load theiframe
inpage1
and display it inpage2
– Patrioticcow Commented Jun 20, 2013 at 20:44
1 Answer
Reset to default 3Loading the iframe content makes the browser cache the page in it, so that if you load it a second time later, the browser will simply fetch it from cache, unless your server is set up to always load the content afresh. I suspect that if you're seeing it reload the iframe's page each time you revisit it, you either forgot to indicate how long the page should be cached for, or your server isn't set up to say "this page has not been modified since ..." so the browser doesn't try to reload the page, or the page is served with a header that indicates it cannot be cached.
(If you want to preload the content for the first run, that's the same thing as loading it in the iframe, with the iframe hidden, and then showing it when the iframe content is ready.)
本文标签: javascripthow to prefetchcache iframe contentStack Overflow
版权声明:本文标题:javascript - how to prefetchcache iframe content? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741969087a2407724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论