question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subsequent Gridsome builds causing 404's with JS assets

See original GitHub issue

Description

I’m running into an issue with a Gridsome site in production, which is being hosted on Netlify, however I would imagine this issue would affect most hosting providers.

Specifically, each time Gridsome builds, new JS assets are generated with new cache-invalidation suffixes. This unfortunately causes issues for users who are already browsing previous versions of the site. When they attempt to browse to a new page, the browser complains that the necessary JS is no longer available (404) and the routing does not occur.

Steps to reproduce

  1. Deploy your site to your hosting provider (e.g. Netlify).
  2. Visit the site in your browser.
  3. Re-deploy your site.
  4. Return to your browser and try to browse around your site (without refreshing your browser).
  5. Things should fail.

I have also been able to reproduce this locally by running gridsome build successively and using a local web server.

Expected result

The site should gracefully recover, perhaps by doing a page refresh??

Actual result

The site crashes with multiple 404 errors in the console relating to missing JS files.

Environment


Libs:
- @gridsome/cli version: v0.0.9
- gridsome version: v0.6.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
hjvedvikcommented, Jun 10, 2019

Yes, I’ve done some testing and a simple fix would be to use location.assign(to.fullPath) in router.beforeEach whenever a route component fails to load or a JSON file for a page doesn’t exist. We’ll try to include a fix next time we publish an update 😃

0reactions
u12206050commented, Sep 20, 2019

Just for reference on how I achieved cache busting in vue pwa: vuejs-pwa-cache-busting

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fast by default - Gridsome
Fast by default. Gridsome builds ultra performance into every page automatically. You get code splitting, asset optimization, progressive images, and link ...
Read more >
Serving Pages - Cloudflare Docs
If Page Rules or other cache settings are used on your custom domain, that may lead to stale assets being served after a...
Read more >
[Support Guide] Frequently encountered problems during builds
JS ! Problems with deploy. Deployment Issue: NPM dependency 404s (Vanilla JS site). Vue Build Failed.
Read more >
Re-open a thread - Community Water Cooler - Prismic People
Preview with Next.js build export? Integrate custom Api not in setting. Security API and freelancer. Tag suggestions per document type.
Read more >
Cannot build Gridsome project: modal causes 'window is not ...
You're right, after importing 'vue-js-modal/dist/ssr.index' instead, and including the plugin you mention, it worked. – nestor556. Feb 13, 2020 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found