mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Add cached-components example
This commit is contained in:
parent
9317340088
commit
ba8327abf4
3
examples/cached-components/nuxt.config.js
Normal file
3
examples/cached-components/nuxt.config.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
cache: true
|
||||
}
|
11
examples/cached-components/package.json
Normal file
11
examples/cached-components/package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "nuxt-cached-components",
|
||||
"dependencies": {
|
||||
"nuxt": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "nuxt",
|
||||
"build": "nuxt build",
|
||||
"start": "nuxt start"
|
||||
}
|
||||
}
|
20
examples/cached-components/pages/index.vue
Normal file
20
examples/cached-components/pages/index.vue
Normal 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>
|
Loading…
Reference in New Issue
Block a user