问题
I've got a site built on Gatsby/Netlify that just recently started having an intermittent issue where some of the js assets return a 404. The issue seems to appear and go away on its own. Here's a screenshot of the devtools console:
What kinds of things should I check?
回答1:
Chances are you have gatsby-plugin-offline
installed and it is caching old files.
The Gatsby community is still looking for ways to 100% solve this issue, but there is a temporary solution that other websites have been using if being a PWA is not incredibly important to your use-case:
- Remove
gatsby-plugin-offline
fromgatsby-config.js
. - Add
gatsby-plugin-remove-serviceworker
togatsby-config.js
. $ yarn add gatsby-plugin-remove-serviceworker
This will:
- Prevent your website from creating service-workers on new visitors.
- Remove service-workers and effectively removing the caching capability from returning visitors.
来源:https://stackoverflow.com/questions/56710367/webpack-runtime-js-files-getting-a-404