6

i have a iframe and it takes a while for for the content to come back. I can't avoid using the iframe, so i'm wondering if i can somehow:

  1. cache the content, so that when i revisit the page, it loads very fast.
  2. 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?

4
  • You could load the iframe but set display: none; until it's required. Commented Jun 20, 2013 at 19:49
  • @Joe. im not sure you get my point. I want the content cached or prefetch 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. Commented Jun 20, 2013 at 20:08
  • @Joe i have age1.html that has a link to page2.html. page2.html has the iframe on it. How can i load the iframe in page1 and display it in page2 Commented Jun 20, 2013 at 20:44

1 Answer 1

3

Loading 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.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.