Comments (9)
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:
- https://angular.io/guide/service-worker-config (for Angular-specific service worker tooling)
- https://developers.google.com/web/tools/workbox/ (for generic service worker tooling that can also work with Angular)
- https://web.dev/offline-cookbook/ (for "vanilla"service worker recipes, without using special tooling)
from sw-appcache-behavior.
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.
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:
- https://unpkg.com/[email protected]/build/index.modern.js
- https://unpkg.com/[email protected]/build/index.umd.js
from sw-appcache-behavior.
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.
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.
After revisit the page, service worker (SW) triggered install and activate events, I can see SW in Dev tools, but no fetch event.
But I can see no clients related in activate event:
After going offline (via tab Network) do I have to refresh again or doing interaction on page?
from sw-appcache-behavior.
clients.claim() inside the activate Event makes no difference.
from sw-appcache-behavior.
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.
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)
- declaration file not found HOT 8
- callback for when new cache is ready HOT 3
- I get a "network error response" when using this on a live website HOT 14
- Is there a way to tell if the cache or network was used for a given response? HOT 7
- Make the name of the 'manifest' attribute configurable HOT 2
- Give the IndexedDB database a more descriptive name that shows where it came from HOT 1
- Potential race condition with ApplicationCache HOT 2
- Broken in Safari 14 ? HOT 3
- Installation issues on Win10 HOT 1
- How best to mimic appcache behaviour using this? HOT 1
- HTML pages added to cache via manifest attribute still contain the hash fragment of the href
- Is there any demo to see this in action? HOT 1
- production readiness HOT 22
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sw-appcache-behavior.