我像这样使用gatsby netlify插件:
resolve: `gatsby-plugin-netlify`,
options: {
headers: {
"/*.js": [
"cache-control: public, max-age=31536000, immutable",
],
"/*.css": [
"cache-control: public, max-age=31536000, immutable",
],
"/sw.js": [
"cache-control: public, max-age=0, must-revalidate",
],
},
},
},但是,当我将更新发布到网站时,浏览器直到手动点击“刷新”后才能看到它。只需访问该站点(不点击刷新)即可显示旧版本。
发布于 2019-06-12 01:33:13
如果您遇到类似的服务工作者缓存问题,则需要将gatsby-plugin-remove-serviceworker安装到应用程序中,以便为您删除服务工作者。这将完成您在上面的netlify配置中尝试完成的工作。
它非常容易设置-只需将其添加到应用程序底部附近的gatsby-config.js中:
module.exports = {
siteMetadata: {
title: 'Your site',
},
plugins: [
// Gets rid of the service worker
'gatsby-plugin-remove-serviceworker'
]
}https://stackoverflow.com/questions/56462811
复制相似问题