Hey,
In the last days I’ve been trying out Http2 (h2) and its push feature that should pack responses to requests not yet invoked to save time. It works and that’s great.

Now I am looking for a way to use this feature to preload api calls (Laravel sanctum takes care of the session) that will be requested by Axios in a JS script when the page loads. I’ve been looking around but I can’t find any documentation on this.

The Js script needs the content of /api/me and /api/events and I’m trying to push this two responses with the main one (first row, document).

In the returned document I have two links that are used by the PHP framework to push the Link headers. This part works, no issue here.

<link rel="preload" href="{{ url('/api/me') }}" as="fetch">
<link rel="preload" href="{{ url('/api/events') }}" as="fetch">

In the first document request (/events) I receive the Link headers and it seems to work regularly but the JS requests don’t use the pushed data and make new requests. Is it even possible to achieve this? How could I troubleshoot/solve this? Can it be some header/caching I should check out?

Many thanks and have a great day!

Post image

Inspection of the requests



Source link

Write A Comment