Home

Issue: 1217

Global server cache

[issue link]

Hi, guys!

I’m using nuxt with express and I want to create global server cache for all requests. I can use lru-cache or something similar, but I don’t know how to pass this data to nuxt.

For example, I have file data.js:

let data = undefined
function getData () {
  return new Promise(function (resolve, reject) {
    if (data) {
      resolve(data)
    } else {
      axios.get('/data')
        .then(response => {resolve(response.data)
        .catch(reject)})
    }
  }
}
module.exports = getData

If I add this file as a plugin, then it will be unique for every request, but how can add it as global?

This question is available on Nuxt.js community (#c1070)