How to clear cache and prevent caching of pages in Ionic

Hi there!

I have an Ionic 2 application based off of the tabs template. As the data in my app is very dynamic and changes frequently on the server, I don’t want any pages to be cached as I navigate back and forth between the tabs. At the moment, I can’t seem to get a parameter-less page to refresh on its own. Accordingly, how can I prevent and/or caching in Ionic 2?

Billy McCafferty

Thanks, but nevermind! :wink:

Hey wmccafferty, I am actually running into the exact same problem. How did you prevent the pages to not be cached in between clicking the different tabs?

Be sure to read the section “Page creation” in the link I included…Pop() and setRoot() are what you’re looking for.

1 Like

Actually after posting something on github, I found my solution to reload data on any tab was to fire OnPageWillEnter

        console.log('****on page will enter messages pane');
            returnedData=>{this.messages = returnedData.global_messages;
1 Like

is there any way to not cache a page by default in RC1?

1 Like

I am in the same situation too. In tabs (rc 4 version of ionic 2), the tabs contents are cached on back button click. How can i disable this caching? Any one has found any solution to this?

Any help will be appreciated! Thanks

I had the same problem and figured you could just set the root twice to force the previous view to refresh. For example:

  if(this.index > -1) {
    this.items.splice(this.index, 1);;
    this.navCtrl.setRoot(HomePage); // previous view will be cached
    this.navCtrl.setRoot(HomePage); // force refresh


Messy, but seems to work fine.

Hey! @PrathimaRao Thanks it helps me :slight_smile:

You can simply implement ionWillEnter Page Event to force refreshing.


Thanks @redlotus it works for me


Could you please confirm that only implementing ionViewWillEnter will fix the cache issue?


There is no such thing. If this is a problem for you, your design is broken.

Sorry for the misunderstanding. This is not a cache issue. I just need the tab view content on PWA application to be refreshed everytime a user loads it.

1 Like