Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a Gatsby site: how do I get the browser to clear the cache? #15623

Closed
noelwelsh opened this issue Jul 11, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@noelwelsh
Copy link

commented Jul 11, 2019

Description

Once a site has been implemented in Gatsby it is difficult to migrate to another framework as Gatsby remains in the browser cache for an excessively long time, causing the old site to continue to render. This can be worked around by manually clearing the cache but it is impractical to expect users to do this.

Steps to reproduce

Create a Gatsby site. View in browser. Move to something else (e.g. static HTML). Gatsby site will still render in the browser until the cache is cleared. This happens months after migrating off Gatsby.

Expected result

New site should render

Actual result

Old Gatsby site renders

Environment

I don't have Gatsby installed any longer, so cannot answer this question unfortunately. However I used latest Gatsby as of several months ago.

@ipatate

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

You have the same problem in multiple browser ? Maybe it's the service worker cache ? clear cache storage.

@noelwelsh

This comment has been minimized.

Copy link
Author

commented Jul 11, 2019

@ipatate

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

it's good solution. But is not gatsby problem, it's service worker problem. Also, you can clear the cache with this solution : https://stackoverflow.com/questions/45467842/how-to-clear-cache-of-service-worker

@wardpeet

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

Copied from the linked thread:

self.addEventListener('activate', function(event) {
  event.waitUntil(
    caches.keys().then(function(cacheNames) {
      return Promise.all(
        cacheNames.filter(function(cacheName) {
          // Return true if you want to remove this cache,
          // but remember that caches are shared across
          // the whole origin
        }).map(function(cacheName) {
          return caches.delete(cacheName);
        })
      );
    })
  );
});

As stated, this is slightly tangential to Gatsby, and it seems like we’ve provided enough information to make an informed decision.

If this is not the case, or if we can help further--please don’t hesitate to reach out or comment on this issue, and we’d love to take another look.

Thanks for using Gatsby 💪

@wardpeet wardpeet closed this Jul 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.