universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

Problem with caching components #32

Closed academici closed 5 years ago

academici commented 5 years ago

Describe the bug Сomponent is not cached. Getting an error: [vue-server-renderer] Component HelloWorld implemented serverCacheKey, but no cache was provided to the renderer.

To Reproduce

  1. Create simple project
  2. Create component example with 10s cache time
    
    <template>
    <div class="hello">
    <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>
3. Run ssr:serve command

**Additional context**

Please indicate versions of:

node: v11.1.0 vue-cli: 3.6.3 uvue: v0.1.0-alpha.18 os: ubuntu 18.04 browser: chrome 73

yabab-dev commented 5 years ago

Good catch, I'll fix this soon!

academici commented 5 years ago

Is it possible to define LRU cache options in server config What do you think?

yabab-dev commented 5 years ago

Actually you can already override this setting in your server.config.js file (and btw fix your current issue)

export default {
  renderer: {
    cache: lruCache(/* your options */),
  }
};
yabab-dev commented 5 years ago

Fixed in 0.1.0-alpha.19