Git Product home page Git Product logo

Comments (5)

userquin avatar userquin commented on August 17, 2024

I assume you're talking about dev server: we configure the entry point to avoid caching any resource, you're in dev mode and so the sw will intercept any request, any change made to the UI will not be updated.

from sveltekit.

kelvindecosta avatar kelvindecosta commented on August 17, 2024

Hey, thanks for the quick response!

I noticed that this is meant for development only, but it seems to be affecting production too.

Note
To clarify what I meant about "previewing", I ran pnpm build && pnpm preview and checked the resulting local website.

Maybe it makes sense to run the following code only in development?

+  if (import.meta.env.DEV) {
 // to prevent service worker from intercepting requests in dev mode
 registerRoute(new NavigationRoute( 
   createHandlerBoundToURL('/'), 
   { allowlist }, 
 ))
+ }

from sveltekit.

userquin avatar userquin commented on August 17, 2024

@kelvindecosta then your app will not work when offline

EDIT: I mean, your service worker will work in both envs, createHandlerBoundToURL will allow work offline (you'll need to add some logic) to avoid chrome dinossour for example... If you're using the sw only to cache assets previous code will work (you can also remove that route from the sw).

from sveltekit.

kelvindecosta avatar kelvindecosta commented on August 17, 2024

Thanks for the information!

To be completely clear, the app seems to work when in offline mode, after the above change.
Here's what I've done:

  • pnpm build && pnpm preview
  • Visit http://localhost:4173 in incognito mode
  • Clear cache (including existing service worker registration)
  • Reload
  • Enable network throttling Offline mode
  • Reload

The app seems to be working fine.

Note

I only see the dinosaur for a split second when I Hard Reload or Empty Cache and Hard Reload. It immediately loads the app from the service worker (confirmed in the Headers > General)

Even the +server.ts routes work fine.

By strictly following the example project code, the +error.svelte pages and +server.ts pages never get rendered, and are always redirected to home, by the sw.

from sveltekit.

jasoneliu avatar jasoneliu commented on August 17, 2024

I'm having the same issue using generateSW #44. Is there a way to get this working with generateSW?

from sveltekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.