Add cached-components example

This commit is contained in:
Sébastien Chopin 2016-12-01 19:01:59 +01:00
parent 9317340088
commit ba8327abf4
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,3 @@
module.exports = {
cache: true
}

View File

@ -0,0 +1,11 @@
{
"name": "nuxt-cached-components",
"dependencies": {
"nuxt": "latest"
},
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start"
}
}

View File

@ -0,0 +1,20 @@
<template>
<div>
<h1>Cached components</h1>
<p>Look at the source code and see how the timestamp is not reloaded before 10s after refreshing the page.</p>
<p>Timestamp: {{ date }}</p>
</div>
</template>
<script>
export default {
name: 'date',
serverCacheKey () {
// Will change every 10 secondes
return Math.floor(Date.now() / 10000)
},
data () {
return { date: Date.now() }
}
}
</script>