I’m sure you can come up with some additions to your service worker script. Take a second look at the image logic, for example:
- When the user requests an image,
- look for a cached version of the image;
- otherwise fetch the image from the network
- and put a copy in the cache.
That doesn’t take into account the worst-case scenario: What if the image can’t be retrieved from the cache or the network? Take a leaf out of the strategy you’re using for HTML—you could add one final conditional step to your image-handling logic:
- Otherwise show a fallback image.
For this to work, you’d need to update your install
event code. The fallback image would need ...
Get Going Offline now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.