I have started working with vue recently, and I have managed to create some simple pages, but I have noticed that the component once loaded are not cached, therefore for example on link below (which is what I am working on) youtube videos take time to load, and if I click on any other link and come back to videos they are loaded again.
Is it possible to use to cache components? preferably all of them instead of 1 by 1.
Here's my vue:
import VueRouter from 'vue-router';
import Create from '../components/homepage/create.vue';
import How from '../components/homepage/how.vue';
import About from '../components/homepage/about.vue';
import Youtube from '../components/homepage/youtube.vue';
import Navigation from '../components/homeNavigation.vue';
import Login from '../components/auth/login.vue';
import Register from '../components/auth/register.vue';
const routes = [
{ path: '/create', component: Create },
{ path: '/how', component: How },
{ path: '/about', component: About},
{ name: 'youtube', path: '/youtube', component: Youtube},
{ path: '/login', component: Login},
{ path: '/register', component: Register},
];
Vue.use(VueRouter);
Vue.component('navigation', Navigation);
const router = new VueRouter({
routes,
});
new Vue({
el: '#app',
router,
updated: function () {
Pace.restart()
},
mounted: function() {
Pace.restart()
}
});
View:
<div id="app">
<navigation></navigation>
<transition appear name="slide-fade" mode="in-out">
<keep-alive include='youtube'>
<router-view></router-view>
</keep-alive>
</transition>
</div>
My app: