You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-8Lines changed: 30 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4278,35 +4278,57 @@ if ('serviceWorker' in navigator) {
4278
4278
4279
4279
- The code above demonstrates how to register a Service Worker for offline capabilities.
4280
4280
- First, it checks if the browser supports Service Workers.
4281
-
- If supported, it registers the Service Worker script (`service-worker.js`) using the `register()` method.
4281
+
- If supported, it registers the Service Worker script (`service-worker.js` - what the script does is outside the scope of this book) using the `register()` method.
4282
4282
- The Service Worker script can intercept network requests, cache assets, and manage offline behavior.
[](https://codesandbox.io/p/sandbox/119-caching-assets-for-offline-use-tmpq6w)
4322
+
4323
+
-[^119]CodeSandbox: Caching Assets for Offline Use.
4324
+
4325
+
[^119]:[CodeSandbox: Caching Assets for Offline Use.](https://tmpq6w.csb.app/), last access: October 11, 2024.
4326
+
4306
4327
- The code above demonstrates how to cache assets for offline use using a Service Worker.
4307
4328
- During the Service Worker installation phase (`install` event), it opens a cache named `my-site-cache-v1`.
4308
4329
- It then adds specified URLs (including HTML, CSS, JavaScript, and image files) to the cache using the `addAll()` method.
4309
4330
- The cached assets can be served from the cache when the user is offline, providing offline access to the application.
4331
+
-**There is a problem with this example in CodeSandbox environment to get it fully working, it's just for your information how it should work, sorry for that.**
0 commit comments