Giter Club home page Giter Club logo

Comments (9)

jeffposnick avatar jeffposnick commented on June 15, 2024

If you have a new project that doesn't already have offline capabilities via AppCache, I would strongly suggest that you do not attempt to add them by using sw-appcache-behavior.

Instead, use a service worker directly. There's more info at:

from sw-appcache-behavior.

Nic2012 avatar Nic2012 commented on June 15, 2024

Thanks for your answer, but this is not the case, this Angular Project is not new it was solved by using the deprecated AppCache. I thought your Projects helps to migrate to service worker?

from sw-appcache-behavior.

jeffposnick avatar jeffposnick commented on June 15, 2024

Sorry, I misinterpreted your request.

You don't have to build anything to use this project, as all of the runtime code is published to npm and can be used via CDNs that mirror npm.

The usage examples at https://github.com/GoogleChromeLabs/sw-appcache-behavior#usage can be followed with, e.g. the UNPKG CDN with the following URLs:

from sw-appcache-behavior.

Nic2012 avatar Nic2012 commented on June 15, 2024

No problem, now I have integrated both libs into my project, on win client side the code works fine. Its nearly the same as y mentioned in https://github.com/GoogleChromeLabs/sw-appcache-behavior#usage, but for the moment in the index.html of my Angular project.
After startup the application I can see the files declared in manifest file can be found now in Cache Storage (Dev Tools in Chrome)

But when I set Network mode to offline also in Dev tools and pushes F5 refreshing the page nothing will be fetched via service worker. Is there any changes in code needed that the fetch event is triggered in service worker code? I was expecting that the code with "event.respondWith(appcachePolyfill.handle(event))" will be fired, too, or I am wrong?

BTW I am using the old version 0.1.0, because latest versions cannot be installed on my Win10 machine, but for this I create new ticket.

from sw-appcache-behavior.

jeffposnick avatar jeffposnick commented on June 15, 2024

It might be that the service worker is installed, but not in control of your current page: https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#clientsclaim

What happens if you close the tab, then revisit the page, and then go offline? Do you see the fetch events firing in that case?

from sw-appcache-behavior.

Nic2012 avatar Nic2012 commented on June 15, 2024

After revisit the page, service worker (SW) triggered install and activate events, I can see SW in Dev tools, but no fetch event.
image

But I can see no clients related in activate event:
image

After going offline (via tab Network) do I have to refresh again or doing interaction on page?

from sw-appcache-behavior.

Nic2012 avatar Nic2012 commented on June 15, 2024

clients.claim() inside the activate Event makes no difference.

from sw-appcache-behavior.

jeffposnick avatar jeffposnick commented on June 15, 2024

I can't tell from your screenshots what URL the service worker script is being served from, but another issue that can sometimes lead to confusion is if your service worker script is located at a subsection of your site, like /scripts/sw_appcache.mjs, in which case the default scope for the service worker would be /scripts/, and only client pages that were also served from /scripts/ would be controlled.

Can you share a link to your deployed site where I can reproduce this issue? That might help debug things quicker.

from sw-appcache-behavior.

Nic2012 avatar Nic2012 commented on June 15, 2024

Yes it seems to be an issue with the scope, I was shortly able to receiving some fetch events when service worker code is located on root where also the Angular main app code will be running. But the project is a bit outdated bundled with old technology that caused during runtime a lot of exception with es6 compiler etc. That needs to be adjusted first.

from sw-appcache-behavior.

Related Issues (14)

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.