fix(prerenderer): HEAD requests cause double requests#594
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes HEAD request handling in the prerenderer to avoid unnecessary full HTML generation. HEAD requests are currently performing the same expensive rendering operations as GET requests (taking 2.5 seconds and generating 878KB of HTML) when they only need to determine status codes.
- Passes
isHeadflag through the rendering pipeline to identify HEAD requests - Returns empty HTML content for HEAD requests while preserving status code determination
- Updates client symlink from src to dist directory
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| prerender-server/src/server.js | Adds isHead flag to render call options to identify HEAD requests |
| prerender-server/client | Updates symlink to point to dist instead of src directory |
| client/src/run-server.js | Returns empty HTML for HEAD requests while preserving status code logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
bd5dacb to
eb1ba8c
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
HEAD /nojs/address/... took 2530ms and returned 878259 bytesThis proves HEAD requests are generating the full HTML body (878KB) and taking 2.5 seconds - the same expensive operation as GET requests.
The code confirms this: in server.js, every request (HEAD or GET) calls render(), which runs the full Cycle.js app to generate HTML. Express handles HEAD by not sending the body, but the work is still done.
The proxy uses HEAD requests to check if pages exist (200 vs 404/500), not to get content-length. The prerender determines status codes without needing the full HTML body.