TsgcWebSocketHTTPServer › Methods › PushPromiseAddPreLoadLinks
Registers an HTTP/2 Server Push rule that preloads a set of related resources whenever a matching request path is served.
public void PushPromiseAddPreLoadLinks(string aPathMatch, TStrings aLinks);
| Name | Type | Description |
|---|---|---|
aPathMatch | const String | Request path that triggers the push, for example /index.html. When a client requests this resource over HTTP/2 the server also pushes the links registered for it. |
aLinks | const TStrings | List of resource paths (one per line) that will be pushed alongside the matched request, such as stylesheets, scripts or images referenced by the primary document. |
PushPromiseAddPreLoadLinks appends a new entry to the internal HTTP/2 push-promise table. Whenever an HTTP/2 client requests the path given by aPathMatch, the server emits a PUSH_PROMISE frame for every link in aLinks before the main response so the client can populate its cache without issuing extra round-trips; see HTTP/2 Server Push for the full workflow. The link list is copied, so the caller is free to free the supplied TStrings after the call. Push promise is only honoured on HTTP/2 connections negotiated via ALPN; HTTP/1.1 clients receive the main response without the promised resources. Call PushPromiseRemovePreLoadLinks to drop the rule.
TsgcWebSocketHTTPServer oServer = new TsgcWebSocketHTTPServer(this);
oServer.PushPromiseAddPreLoadLinks("/index.html", "/styles.css");