【发布时间】:2021-10-11 20:17:00
【问题描述】:
我有一些来自 node_modules 的文件,它们需要保存在缓存中,因为我正在获取这些信息
为了获得我使用 Lighthouse 审核的这些信息,这是网络 https://www.webpagetest.org/
这是最终结果,“缓存静态内容”是错误 enter image description here
我正在与 Gatsby 合作,我找到了有关我的问题的信息https://www.gatsbyjs.com/docs/caching/#javascript-and-css,但我不确定如何使用它或者我应该使用其他库吗?我不知道如何缓存
我认为我应该使用这些属性:
The cache-control header should be cache-control: public, max-age=31536000, immutable
这是我的文件 gatsby-config
plugins: [
'gatsby-plugin-top-layout',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'assets',
path: `${__dirname}/src/assets`,
},
},
`gatsby-plugin-image`,
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-plugin-manifest',
options: {
},
},
{
resolve: `gatsby-plugin-offline`,
options: {
precachePages: ['/projects/'],
},
},
{
resolve: 'gatsby-plugin-material-ui',
我这样做的目的是解决这个问题,当我重新加载 Web 应用程序时会有一个空格
【问题讨论】:
-
您将需要从您的 Web 服务器而不是您的静态内容 (gatsby) 发送这些 HTTP 标头。你用的是什么网络服务器?
-
@nita 我正在使用 firebase
标签: reactjs firebase server strapi