Closed viktorstrate closed 4 years ago
Hey man, you need to follow the Django file structure conventions.
Are you refering to the service-worker.js
not being located under /static/
? If not please correct me.
I needed to move the service worker to the root, otherwise it can only be used for files under the /static/
subdirectory. This has to do with the scope of service workers, and this was acually the reason why it didn't work before.
See Google's Introduction to Service Worker - Registration and Scope
The scope of the service worker determines which files the service worker controls, in other words, from which path the service worker will intercept requests. The default scope is the location of the service worker file, and extends to all directories below. So if service-worker.js is located in the root directory, the service worker will control requests from all files at this domain.
Because of this it is the standard to always have the service worker at the root of the site.
It is possible to have a service worker, under a subdirectory, control the root of the site, but a HTTP header would have to be set by the server to allow this, as this can be a security problem. See Service-Worker-Allowed HTTP Header
Edit: See this Stack Overflow question for service workers in Django https://stackoverflow.com/questions/38696595/django-and-service-workers-serve-sw-js-at-applications-root-url
I guess we need to test it first. The PR looks :fire: But can you apply few changes.
Tutorial DB
to tutorialdb
(all lowercase)I've changed name and logo in the latest commit
@viktorstrate Thanks for your contributions :tada: , the changes will be live soon. Sorry for the late merge :crying_cat_face:
@all-contributors please add @viktorstrate for code
@Bhupesh-V
I've put up a pull request to add @viktorstrate! :tada:
This pull request, resolves #36
Lighthouse result