src/docs/markdown/caddyfile/directives/push.md
Configures the server to pre-emptively send resources to the client using HTTP/2 server push.
Resources can be linked for server push by specifying the Link header(s) of the response. This directive will automatically push resources described by upstream Link headers in these formats:
<resource>; as=script<resource>; as=script,<resource>; as=style<resource>; nopush<resource>;<resource2>;...where <resource> begins with a forward slash / (i.e. is a URI path with the same host). Only same-host resources can be pushed. If a linked resource is external or if it has the nopush attribute, it will not be pushed.
By default, push requests will include some headers deemed safe to copy from the original request:
as it is assumed many requests would fail without these headers; these do not need to be configured manually.
Push requests are virtualized internally, so they are very lightweight.
push [<matcher>] [<resource>] {
[GET|HEAD] <resource>
headers {
[+]<field> [<value|regexp> [<replacement>]]
-<field>
}
}
header directive. Some headers are carried over by default and do not need to be explicitly configured (see above).Push any resources described by Link headers in the response:
push
Same, but also push /resources/style.css for all requests:
push * /resources/style.css
Push /foo.jpg only when /foo.html is requested by the client:
push /foo.html /foo.jpg