2

Found the following line in a javascript library that is used for predictive text in search boxes. Ex: If you type "red" a list pops up with "red dress, red flowers, red cars, etc"

// Write the cache busting IFRAME
document.write('<iframe style="height:0px;width:0px;visibility:hidden;display:none;" src="about:blank">this prevents back forward cache</iframe>');

I don't see how an empty iframe can bust cache. I've seen people append random numbers to the end of links to bust cache...but what is this iFrame all about. The library is big so I can share it. Sorry if this is not enough code to declare an answer.

Alex
  • 852
  • 1
  • 10
  • 21

1 Answers1

1

It's a Safari browser behavior. From the Apple Developer docs:

Safari's Back/Forward cache (the cache pulled from when a visitor presses the Back or Forward browser buttons) can also be thwarted by insuring that your page contains a frame. Frame-based pages are never stored in the back / forward cache and you can insure your non-frame based page behaves similarly by adding the invisible iframe below.

source

Rodney Folz
  • 6,709
  • 2
  • 29
  • 38
  • So if I already have an iFrame on my page I can remove this line of code? – Alex Nov 11 '14 at 00:22
  • Yes, but if that line of code is from a third-party library I'd just leave it be. Having an extra blank iframe won't hurt anything. – Rodney Folz Nov 11 '14 at 00:24