Force page caching


#1

Hi,
I have a page with an iframe inside. I don’t want the iframe to reload its content everytime I change the page, but since the page is not cached, it’s removed from the DOM on page change.

Would forcing the page to cache solve the problem?
If so, how do I do that? Couldn’t find anything about it on the doc.
I’m using the latest version of ionic.

Thanks!


#2

Iframes don’t play well with Angular in my experience. So I think you should look into other ways to deliver that content. That said, do you want it to appear on every page? If so, you could put it in app.html and see how it looks.


#3

No, it appears on a single page.
My current solution is to have an iframe in app.html and show it on top when I’m on that specific page.
Since I’ve read about caching I thought there was a way of flagging a page so it’s not removed from the DOM.


#4

You could store it locally, either in a provider or in local storage. (Or even session storage if you expect the iframe to change content a lot.) On the first render, you do your expensive long distance write, and then after that, you get the info from the provider or the device. That’s different from caching the page, which Ionic doesn’t support. Probably storing in Ionic Storage is the solution that will be most robust across platforms. But maybe your app.html solution is faster.


#5

It’s dynamic content I’m loading from a remote src, so it can’t be stored.
I guess I’ll stick with the workaround :wink: thanks!