A file inside /statics/sw.js will work the same way as one inside the project root??
Won’t work, it will only have access to fetch events that begin with /statics
Reference:https://developers.google.com/web/fundamentals/primers/service-workers/? hl=en
A subtle point of the Register() method is the location of the service worker file. In this case, you will notice that the service worker file is at the root of the domain. This means that the scope of the service worker will be the full source. In other words, this service worker will receive fetch events for everything in that domain. If we register the service worker file in /example/sw.js, it will only see the fetch events of the URL pages starting with /example/ (i.e., /example/page1/, /example/page2/).
When you register the Voce SW you can set the scope
navigator.serviceWorker.register('/statics/sw.js', {scope: '/'})
– David Schrammel
I tried that, and returned an error saying it was above the allowed scope and asked to move the file to the folder
/statics
and define the scope for/statics
also– LeonardoEbert
This is the error I return when I set the scope:
The path of the provided scope ('/') is not under the max scope allowed ('/statics/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.
– LeonardoEbert