How to install a Service Worker
Service Worker is a script that your browser runs in the background, separate from the Web, enabling features such as periodic synchronization, push notifications and even running offline.
To create the script, follow the step-by-step instructions below:
- In the VTEX Admin, go to Store Settings > Storefront > Checkout, or type Checkout in the search bar at the top of the page.
- Click the icon of the desired site.
- In the
Code
tab, click theNew
buttton. - Then click on
File
. - Fill in the file name exactly like:
service-worker.js
. - Click the
Create
button. - Set the feature.
- Click the
Save
button.
Although the file is in /files/service-worker.js
, it receives the Service-Worker-Allowed
header with the value /
, which allows you to intercept requests from the site root.
For more information, see Google Developers Web Fundamentals.