Refresh page using cache

Posted by cbh on Stack Overflow See other posts from Stack Overflow or by cbh
Published on 2011-06-28T04:56:34Z Indexed on 2011/06/28 8:22 UTC
Read the original article Hit count: 153

Filed under:
|
|

I am trying to refresh a page, but WANT to use the cache and can't figure out how to do this. There are two situations:

  • If I click in the URL bar and hit enter (or visit the page from somewhere else) it reloads the page/images from the cache. GREAT!

  • If I click on the refresh button or use Javascript to refresh the page it grabs all the images again and takes forever. NOT GREAT!

I've tried: top.location.reload(false); and top.location.reload(true); (I'm sending this from in an iFrame) and neither used the cache. I'm avoiding using location so it doesn't end up in the browser history twice.

Question: How do I reload the page using the cached images? Is there a different javascript function or is this a mod_expires issue?

Thanks for any help in advance!

EDIT: (info from chrome: developer tools)

  • When navigating to the page I get "From Cache" for all images
  • When refreshing page I get "304 - Not Modified" for all images (and it takes the time to download each)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about caching