Nuxt 高效缓存

Nuxt Efficient Cache

使用高效缓存策略提供静态资产。如果我审核我的应用程序,我会得到这个。我将此代码添加到 nuxt.config 但这会有所帮助。

render: {
  static: {
    maxAge: 2592000
  }
},

它默认在浏览器中缓存静态资产 1 小时。 哪里可以修改。或者如何?

您应该使用 Firebase 为您的静态文件配置 headers:

https://firebase.google.com/docs/hosting/full-config#headers

// in firebase.json
"hosting": {
  // ...

  // Add the "headers" attribute within "hosting", override cache control
  "headers": [ {
    "source": "**/*.@(jpg|jpeg|gif|png)",
    "headers": [ {
      "key": "Cache-Control",
      "value": "max-age=2592000"
    } ]
  }
 ]
}

这应该会为您提供所需的缓存控制值,具体取决于您要在此处设置的内容。