I want to "push" additional resources (HTML fragments mostly, but also CSS and images) upon requesting a particular HTML fragment using the browser XMLHttpRequest or Fetch API. I know how to construct an HTTP/2 response on the server side, and also how server-sent resources can be pushed into a browser cache for regular page loads, but my question is specifically about HTTP/2 server push responses initiated programmatically via JavaScript, eg. can I push additional resources on an Ajax request, and count on those pushed resources being served from the browser cache when I fetch those resources in a subsequent XHR request explicitly (Cache-Control and other headers for conditional requests permitting)? Will pushed resource responses being cancelled if they are already cached?
can I push additional resources on an Ajax request, and count on those pushed resources being served from the browser cache when I fetch those resources in a subsequent XHR request explicitly (Cache-Control and other headers for conditional requests permitting)?
Yes. However you need to be aware of various difficulties in push and in particular credentialed versus uncredentialled connections.
Will pushed resource responses being cancelled if they are already cached?
Should do though very browser dependent and also may be already downloaded by the time the cancel request makes it back.