From 2c2fc769a01d236c7dfdfde0c1f65ab77a71381a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:24:49 +0000 Subject: [PATCH 1/2] Initial plan From 74c2cc5aac8b8eb2068943044936613ac5cb8120 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:29:43 +0000 Subject: [PATCH 2/2] Implement HTTP 103 Early Hints for main page performance optimization Co-authored-by: BrooksCunningham <22921241+BrooksCunningham@users.noreply.github.com> --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main.rs b/src/main.rs index 6df0b29..bb1f333 100644 --- a/src/main.rs +++ b/src/main.rs @@ -327,6 +327,9 @@ fn status_result(status_u16: u16, mut resp: Response) -> Result /// This is the default handler for the root path `/` and displays /// the OpenAPI documentation interface. /// +/// Uses HTTP 103 Early Hints to preload critical resources before sending +/// the full HTML response, improving page load performance. +/// /// # Arguments /// /// * `resp` - The response object to populate @@ -339,6 +342,29 @@ fn status_result(status_u16: u16, mut resp: Response) -> Result /// /// Returns an error if the KV store lookup fails. fn swagger_ui_html(mut resp: Response) -> Result { + // Send HTTP 103 Early Hints to preload critical resources + // This allows the browser to start fetching these resources + // before the full HTML response is sent + let early_hints = Response::from_status(103) + .with_header( + "Link", + "; rel=preload; as=style", + ) + .with_header( + "Link", + "; rel=preload; as=script", + ) + .with_header( + "Link", + "; rel=preload; as=script", + ) + .with_header( + "Link", + "; rel=preload; as=fetch; crossorigin", + ); + + early_hints.send_to_client(); + // Define a KV store instance using the resource link name let store: KVStore = KVStore::open(KV_STORE_NAME)?.unwrap();