// pages/+vue.tsimport type { Config } from 'vike/types'export default { keepAlive: true} satisfies Config['vue']
Instead of true, you can provide <KeepAlive> props for controlling which page components are cached:
// pages/+vue.jsexport default { // Cache at most 10 page instances, and never cache the component named 'HugePage' keepAlive: { max: 10, exclude: ['HugePage'] } }
// pages/+vue.tsimport type { Config } from 'vike/types'export default { // Cache at most 10 page instances, and never cache the component named 'HugePage' keepAlive: { max: 10, exclude: ['HugePage'] } } satisfies Config['vue']
The include/exclude props match against the name of your +Page.vue components.
You can use Vue's onActivated() and onDeactivated() lifecycle hooks inside your page components to react to the page being shown/hidden.