【问题标题】:my gatsby site on netlify doesnt get refreshed on update我在 netlify 上的 gatsby 网站在更新时没有刷新
【发布时间】:2019-10-21 02:25:44
【问题描述】:

我正在像这样使用 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",
          ],
        },
      },

    },

但是,当我向网站发布更新时,浏览器在手动点击“刷新”之前不会看到它。只需访问该网站(无需点击刷新)即可显示旧版本。

【问题讨论】:

  • 我在使用服务人员时遇到了类似的问题。我删除了 gatsby service worker 插件,它解决了我遇到的一些缓存问题。

标签: gatsby netlify


【解决方案1】:

如果您遇到像这样的 Service Worker 缓存问题,您需要将 gatsby-plugin-remove-serviceworker 安装到您的应用程序中,这将为您删除 Service Worker。这将完成您在上面的 netlify 配置中尝试做的工作。

设置非常简单 - 只需将其添加到应用程序底部附近的gatsby-config.js

module.exports = {
  siteMetadata: {
    title: 'Your site',
  },
  plugins: [
    // Gets rid of the service worker 
    'gatsby-plugin-remove-serviceworker'
  ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-13
    • 1970-01-01
    • 2018-09-20
    • 2020-05-29
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多