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

Implement API to reject PUSH_PROMISEs sent by the server over HTTP/2 #796

Closed
mariusGundersen opened this issue Dec 3, 2015 · 3 comments
Closed
Milestone

Comments

@mariusGundersen
Copy link

HTTP/2 has support for the server pushing content to the client before the client requests it. This is specified as the server sending a PUSH_PROMISE to the client with (at least) the method and url to the resource. The server can then start sending the response to the client before the client has requested it.

The spec does not specify how long the server should wait until it starts sending the response, so it can send it right away or it can choose to wait for a little while. If, while waiting, the server receives a RST_STREAM message from the client on the (stream of the) resource, then the server should interpret that as the client having rejected the content. This can be done for example if the client already has the content in it's cache, and therefore doesn't need it.

It would be useful if this could be handled by the ServiceWorker, since the ServiceWorker has a cache. The ServiceWorker could have a pushPromise event with the url as part of the event object, and a reject method that sends the RST_STREAM to the server. This could then be used to check if the url is in the ServiceWorkers cache, for example:

this.oninstalled = function(){
  caches.set('myCache', new Cache());
}

this.addEventListener('pushPromise', function(event){
  //if the request url is in the cache,
  //then we don't need the server to send it to us,
  //so we reject it
  caches.match('myCache', event.request.url).then(event.reject);
});
@annevk
Copy link
Member

annevk commented Dec 15, 2015

I think we want a more generic API and not require service workers to be able to deal with H2 push. whatwg/fetch#51 has some discussion and ideas, but not much progress yet.

@jungkees
Copy link
Collaborator

jungkees commented Jan 7, 2016

Tagging it Future ideas in favor of whatwg/fetch#51 until we see some concrete proposal.

@jungkees jungkees added this to the Future ideas milestone Jan 7, 2016
@jakearchibald
Copy link
Contributor

Closing for now, can reopen if it comes back to us

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

4 participants