简体   繁体   English

Gatsby 插件离线不缓存文件

[英]Gatsby plugin offline not caching the files

I am working with gatsby PWA.我正在与盖茨比 PWA 合作。 Here is the list of errors when audit using lightbox.以下是使用灯箱审核时的错误列表。

在此处输入图片说明

The problem is either my service worker is not working or not caching the pages and I am sure there is something wrong with my configuration in gatsby.config.js .问题是我的 service worker 不工作或没有缓存页面,我确定我在gatsby.config.js配置有gatsby.config.js Pls help请帮忙

  {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `icon.png`, // This path is relative to the root of the site.
      },
    },
    {
      resolve: `gatsby-plugin-offline`,
      options: {
        workboxConfig: {
          globPatterns: ["**/*.{js,jpg,png,html,css}"],
        },
      },
    },

In your LightHouse Report click at the "PWA"-Icon (Circle) above.在您的 LightHouse 报告中,单击上方的“PWA”-图标(圆圈)。 This scrolls you down to the given section of it.这会将您向下滚动到它的给定部分。 There you found some notices, why the PWA couldn't established for this page.您在那里找到了一些通知,为什么无法为此页面建立 PWA。

There can be many reasons for this like:造成这种情况的原因可能有很多,例如:

  • page is not available via HTTPS://页面无法通过 HTTPS:// 访问
  • there is no canonical-Tag没有规范标签
  • Icon for Manifest was not found未找到清单的图标
  • manifest has issues / errors清单有问题/错误

So maybe share the url so that other ones can have a look at it to help you, or post some screenshots about the PWA-Section (or some request with detailed questions).因此,也许可以共享 url,以便其他人可以查看它以帮助您,或者发布一些有关 PWA 部分的屏幕截图(或一些带有详细问题的请求)。

BTW : Even if your gatsby-config looks ok, I recommend to go with the defaults first.. so remove the "workboxConfig-Stuff... and for your manifest-section choose standalone for display .顺便说一句:即使您的 gatsby-config 看起来没问题,我还是建议先使用默认值。所以删除“workboxConfig-Stuff... 并为您的清单部分选择standalonedisplay

Good Luck.祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM