Alexander Demianenko
Alexander Demianenko

Reputation: 124

Access parent window cache from iframe

I have a carousel with about 20 images. When all images are loaded, they should be cached, and then loaded once again in an iframe. Browser shows that images are cached.

The issue is the same image URL in an iframe downloading them once again, not loading from the cache. Is there any way to load these images from cache?

Upvotes: 0

Views: 575

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074475

The browser's cache is not window-specific.

If your images are getting re-requested, it's because one of these things is true:

  1. (Unlikely) The URL is different (even if your server ends up returning the same image), or
  2. (Likely) The caching headers, etc., being sent back with the images are telling the browser not to cache them, or
  3. The browser decided not to cache them even though it is allowed to for whatever reason (e.g., its caching heuristics said "don't cache these").

To fix it, ensure that your URLs to the images evaluate to the same full URL (they probably already do, but double-check), and that the server sends back sufficient caching information to allow the browser to cache the images.

Upvotes: 1

Related Questions