h2.push

VOIDh2.pushSTRINGresourceSTRINGas

Available in all subroutines.

Preemptively sends a response to the client for resource. The push will happen immediately when the function executes, regardless of what happens with the request being processed.

The pushed resource can be a relative or absolute path, but must share the same host as the current request.

Clients can disable pushes via the SETTINGS frame and a given resource will only be pushed once per connection.

Example

sub vcl_recv() {
if (fastly_info.is_h2 && req.url == "/") {
h2.push("/style.css");
h2.push("/script.js");
h2.push("img.jpg");
}
}

Try it out

h2.push is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

H2 Server Push

Send required resources along with page responses, before the resources are requested by the browser.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.