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

should FetchEvent.request ever be a range request if we cannot verify if the underlying resource is the same? #1201

Open
wanderview opened this issue Sep 28, 2017 · 7 comments

Comments

@wanderview
Copy link
Member

It seems that in firefox we avoid using partial response and range requests if:

  1. The server cannot support range requests
  2. The underlying resource has changed since the previous part of the resource was received

See:

https://searchfox.org/mozilla-central/source/netwerk/base/nsIResumableChannel.idl#13

If we allow range requests through FetchEvent.request, how can we ever know if the underlying resource has changed? Normally we depend on the http cache to detect if a change has taken place, but we don't have that here. The service worker could return completely different data each time.

Does chrome have similar "detect if something changed" behavior for range requests?

@wanderview
Copy link
Member Author

As far as I can tell the fetch spec does not indicate when the Range header should be added to the request. In gecko we only add it in "network or cache" path here:

https://searchfox.org/mozilla-central/source/netwerk/protocol/http/nsHttpChannel.cpp#4208

@annevk, is this something fetch spec should include?

@wanderview
Copy link
Member Author

Gecko bug for this issue:

https://bugzilla.mozilla.org/show_bug.cgi?id=1404041

@annevk
Copy link
Member

annevk commented Sep 29, 2017

@wanderview yeah, @jakearchibald has some work-in-progress on range requests here: whatwg/fetch#560.

@jakearchibald
Copy link
Contributor

Yeah, I need to pick that back up again

@wanderview
Copy link
Member Author

That PR looks useful to clarify some things, but does it address the checking for change question? Maybe firefox is more conservative here, but we never use range request unless we can have some assurance that we're continuing the same resource from before. All the logic that enables that is in the http cache which sits below the service worker.

@jakearchibald
Copy link
Contributor

@wanderview here's the other part of it whatwg/html#2814.

I'll also work on how to resume downloads, which we also need for background fetch.

You might be interested in my tests https://github.com/jakearchibald/range-request-test - Firefox is the only browser that does well.

@wanderview
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants