# Disable IonRouterOutlet Component Caching

**URL:** <https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440>\
**Category:** Ionic Vue\
**Created:** [March 16, 2022, 4:12pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440 "2022-03-16T16:12:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicoHof](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@NicoHof](https://forum.ionicframework.com/u/NicoHof)\
**Post date:** [March 16, 2022, 4:12pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/1 "2022-03-16T16:12:50Z")

</div>

Hi!

I am using Ionic vue and ionic vue router in version 6.0.x.  
I noticed, that the IonRouterOutlet component is caching visited pages.

This looks like a nice feature in the first place. And it will be useful in most of the cases to improve app performance and save server requests.

But in some cases I want to force to re-render the page (component) every time when I come back later to that page. I did not find **any way** to disable caching / keep alived components. It would be just fine to destroy the component when leaving the component / page.

How can I reach this?

---

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [March 16, 2022, 9:26pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/2 "2022-03-16T21:26:50Z")

</div>

take a look at the specific page lifecycle events from Ionic - [Vue Lifecycle | Ionic Documentation](https://ionicframework.com/docs/vue/lifecycle#guidance-for-each-lifecycle-method)

---

<div class="post-metadata">

**Author:** ![NicoHof](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@NicoHof](https://forum.ionicframework.com/u/NicoHof)\
**Post date:** [March 18, 2022, 11:23am UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/3 "2022-03-18T11:23:20Z")

</div>

Hi @aaronksaunders Thank you for your reply and the link to the docs! It helps a bit!  
The docs explain well how it works and why it works like this.

But I could not find any information about disabling or changing the described behaviour.

A workaround in my scenario is kind of possible with the lifecycle hooks. But the better solution would be to completely destroy the “cached” pages in some cases.

I am missing kind of an option like “keepAlive” in router settings or smth similar.

Best, Nico

---

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [March 18, 2022, 12:52pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/4 "2022-03-18T12:52:15Z")

</div>

There is no way to do what you want with the ionic router

---

<div class="post-metadata">

**Author:** ![mirko77](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirko77/32/137216_2.png) [@mirko77](https://forum.ionicframework.com/u/mirko77)\
**Post date:** [March 21, 2022, 2:16pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/5 "2022-03-21T14:16:54Z")

</div>

You need a watcher, and in your routes pass a parameter like a timestamp when you want to bust the cached component.

Like:

```auto

watch(
	() => [
		{
         timestamp: route.params.timestamp
		}
		],
		(changes) => {
			if (changes[0].timestamp) {
				//refresh
			}
		}
);

```

Then route to your components using

```auto
 router.replace({
   name: {your route name},
   params: { timestamp: Date.now() }
 });

```

---

<div class="post-metadata">

**Author:** ![NicoHof](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@NicoHof](https://forum.ionicframework.com/u/NicoHof)\
**Post date:** [March 21, 2022, 2:35pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/6 "2022-03-21T14:35:40Z")

</div>

@mirko77 Thank you for your suggestion.

Actually I am using something similar right now (watching route object in view component) to check if I come back to an existing route/component.

It works but still feels like a workaround for me.

An option in the router like “cache” true/false or “keepalive” would feel cleaner IMO.

---

<div class="post-metadata">

**Author:** ![mirko77](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirko77/32/137216_2.png) [@mirko77](https://forum.ionicframework.com/u/mirko77)\
**Post date:** [March 21, 2022, 5:42pm UTC](https://forum.ionicframework.com/t/disable-ionrouteroutlet-component-caching/221440/7 "2022-03-21T17:42:40Z")

</div>

There is no way to do it out of the box in vue router, unfortunately.
