can I use the HTTP2 Server push mechanism to update a resource that is already known to the client?
Example:
I have some resource under https://myserver.org/myresource.json
that returns {"state": "off"}
Once the state changes form "off" to "on", I want to push {"state": "on"}
to the client under the same url (i.e. https://myserver.org/myresource.json
).
Thanks for your support!
You can push it, but it will only update the clients cache and not change anything in the webpage. In order to do that you need the client to refetch the resource (through XHR/fetch), which might use the value directly from cache.
You can find some examples around that here: https://www.igvita.com/2013/06/12/innovating-with-http-2.0-server-push/ in the chapter Client-notifications for server push.
I personally have not found too much use for it and would rather send the updated content directly through websockets or SSE.