Skip to content
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

feat(http): Add pages for Service Workers #37230

Merged
merged 11 commits into from
Dec 19, 2024

Conversation

bsmth
Copy link
Member

@bsmth bsmth commented Dec 16, 2024

Description

Additions:

  • Service-Worker HTTP header
  • Service-Worker-Allowed HTTP header

Changes:

  • Linking to these docs where it makes sense.
  • Improvements to wording in register() SW page for clarity

Related issues and pull requests

Fixes #34854

@bsmth bsmth requested review from a team as code owners December 16, 2024 14:57
@bsmth bsmth requested review from wbamberg and hamishwillee and removed request for a team December 16, 2024 14:57
@github-actions github-actions bot added Content:WebAPI Web API docs Content:HTTP HTTP docs size/m [PR only] 51-500 LoC changed labels Dec 16, 2024
Copy link
Contributor

github-actions bot commented Dec 16, 2024

Preview URLs

Flaws (2)

Note! 3 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/HTTP/Headers/Service-Worker
Title: Service-Worker
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: http.headers.Service-Worker

URL: /en-US/docs/Web/HTTP/Headers/Service-Worker-Allowed
Title: Service-Worker-Allowed
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: http.headers.Service-Worker-Allowed
External URLs (1)

URL: /en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
Title: Using Service Workers

(comment last updated: 2024-12-19 23:06:42)

## Directives

- `<scope>`
- : A string representing a URL that defines a service worker's registration scope; that is, what range of URLs a service worker can control.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, but perhaps we should capture that it is the top level directory?

Suggested change
- : A string representing a URL that defines a service worker's registration scope; that is, what range of URLs a service worker can control.
- : A string representing a URL that defines a service worker's registration scope; that is, a URL that defines the root path of the range of URLs that a service worker can control.

## Directives

- `<scope>`
- : A string representing a URL that defines a service worker's registration scope; that is, what range of URLs a service worker can control.
Copy link
Collaborator

@hamishwillee hamishwillee Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, what counts as a valid URL? Relative URLs? Absolute URLs? What if there are query parameters? What if this is a file? Is it relative to the site root?

Usually these kinds of headers take either absolute or relative URLs (to site root), and query parameters are stripped along with any credentials and file names. But sometimes the rules are different, so we should say.

<td>{{Glossary("Response header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, we might want to discuss whether we want this table row on response headers at all, seeing as it's always No except for Set-Cookie.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone else agree that we should move the Forbidden XYZ lists from the the glossary into the HTTP documentation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, great idea, I think it might be time to do that

- {{HTTPHeader("Service-Worker")}}
- : Included in fetches for a service worker's script resource.
This header helps administrators log service worker script requests for monitoring purposes.
- {{HTTPHeader("Service-Worker-Allowed")}}
- : Used to remove the [path restriction](/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#why_is_my_service_worker_failing_to_register) by including this header [in the response of the Service Worker script](https://w3c.github.io/ServiceWorker/#service-worker-script-response).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this description to, in particular, remove the spec link. Should be something along the lines of "Use allow a service worker to be registered to a broader scope that allowed by its URL location ..."

Comment on lines 103 to 104
- In Firefox, Service Worker APIs are hidden and cannot be used when the user is in [private browsing mode](https://bugzil.la/1320796), or when history is disabled, or if cookies are cleared when Firefox is closed.
- In Chrome, registration fails when the "Block all cookies (not recommended)" option is enabled.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this into BCD?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good 👍🏻

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see f6de952

Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I did some minor nit fixes (which I hope are OK) and merging. Hurrah

@hamishwillee hamishwillee merged commit 3cb8c59 into mdn:main Dec 19, 2024
8 checks passed
@bsmth bsmth deleted the 34854-service-worker-allowed branch December 20, 2024 12:51
allan-bonadio pushed a commit to allan-bonadio/content that referenced this pull request Dec 25, 2024
* docs(http): service-worker-allowed header

* feat(http): Add pages for Service Workers

* Apply suggestions from code review

Co-authored-by: Hamish Willee <[email protected]>

* Update files/en-us/web/http/headers/service-worker/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore(http): reword common pitfalls for service worker registration failures

* Apply suggestions from code review

---------

Co-authored-by: Hamish Willee <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTTP HTTP docs Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New page for Service-Worker-Allowed
3 participants