Service Workers are scripts that run in the background, separate from a webpage. They enable features such as push notifications, background syncing, and low-level control over requests and caching. There has been buzz about progressive web apps, but I had trouble finding clear resources for caching with service workers. The best is The Offline Cookbook by Jake Archibald.
VR applications typically come with many assets. Loading times are magnified when the user is in the headset. Service workers are great to speed up subsequent visits. If everything is cached correctly, next the a user visits the VR site, the site will load much faster. Below is a quick guide for accomplishing two things:
Testing the Service Worker
To see if the service worker is caching, use the browser developer tools:
In the network panel, the browser developer tools will also tell us when a file is fetched from cache or from the network (or both, in case of background update for cache-then-network):
Have fun caching!
We just sent you an email. Please click the link in the email to confirm your subscription!