Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A good method for client-side iframe caching

I'm trying to cache some documents client-side in order to switch between them faster.

The documents have been loaded in an iframe, so it's a question on how to cache it locally within the browser.

My method was to have a variable, item, and then do

if (item.cache) {
    $('.holder', someElem).html(item.cache);
    return;
}

item.cache = $('<iframe....');
$('.holder', someElem).html(item.cache);

However, this method keeps reloading the iframe src, when injected on to the holder.

Any good methods for client-side iframe caching?

like image 657
freeall Avatar asked Mar 04 '26 12:03

freeall


1 Answers

The iframe doesn't actually trigger a page refresh until it has been added to the dom. I am guessing you keep an instance of the iframe but not add it to the dom until its time to see it. This method doesn't work well. I would suggest using css "display:none" to load it and hide and then show it when you need it.

like image 126
Amir Raminfar Avatar answered Mar 06 '26 00:03

Amir Raminfar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!