-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service Worker route handling refactor #1859
Service Worker route handling refactor #1859
Conversation
… is not mentioned. Weird.
Co-Authored-By: Andy Terranova <[email protected]>
…gento/pwa-studio into revanth/serviceWorkerRefactor
Do not worry about the number of changes, that is because this PR is based on changes that are yet to be merged as part of #1832 |
|
|
||
workbox.routing.registerRoute( | ||
new RegExp('/.\\.js$'), | ||
new RegExp('(robots.txt|favicon.ico|manifest.json)'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick regex gotcha: that .
actually matches on any character. If you want the literal .
, it needs to be escaped: \.
.
Doesn't prevent a 👍 , just an fyi :)
Description
This PR rearranges Service Worker routes to match that of UPWARD. For now, it does not produce any significant changes but this needed to fix other issues. Also, this adds a new route that matches
robots.txt
,manifest.json
andfavicon.ico
. So you should be seeing them being served from the service worker expect for the first time. The service worker uses the stale while revalidate strategy to serve these files, meaning it will return what it has immediately to the UI and then fetches the files in the background and updates them in the cache for later use.Related Issue
Closes #1857
Verification Steps
favicon should be cached on the client. This should be verifiable by looking at the network tab or the caches tab in chrome dev tools.
It is not working as of now in
stage
mode and a bug has been logged #1861.Checklist
Just a casual sanity check should be enough.