Prevention of views caching once loaded in view

As per docs

When you navigate to a new page, Ionic Framework will keep the old page
 in the existing DOM, but hide it from your view and transition the new page.

Can we somehow prevent this from happening if we don’t want to cache pages already visited?

I am using

"@ionic/vue": "5.4.0",
"@ionic/vue-router": "5.4.0",
1 Like

I haven’t looked at the source code, but if you have no intention of navigating back to a page, use router.replace instead of push. The reason for caching is so that back navigation can be done smoothly.

router.replace does not seem to work like that, I’ve check window.history and even though history.state.back is equal to null… it still goes back if you swipe left on iOS

router.replace does not help view is still in DOM cached

If you need to repopulate the date of each fields, or a list view, then you could use ionViewWillEnter() which can accomodate the code that will collect fresh data, something like this:

async ionViewWillEnter() {
this.showLoader();
await this.fetchData();
this.hideLoader();
}