feat: Add build-time Caddy early hints generation#155
Conversation
Summary of ChangesHello @gocanto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant performance optimization by implementing build-time generation of HTTP Early Hints for the Caddy web server. By proactively identifying critical assets from the built HTML, the system can now instruct browsers to preload these resources, potentially reducing perceived page load times and improving user experience. The changes span across build scripts, Caddy configurations, and Docker setup to seamlessly integrate this new capability into the deployment pipeline. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR adds HTTP Early Hints support to the Caddy web server. It introduces a Node.js build script that scans HTML files for external resources, generates corresponding Early Hints directives, and embeds them into Caddy configuration snippets. The changes include build infrastructure updates, new Caddy imports, and Docker configuration to support the generated snippets. Changes
Sequence DiagramsequenceDiagram
participant npm as npm/package.json
participant make as Make
participant script as generate-early-hints.mjs
participant html as dist/index.html
participant caddy as caddy/snippets/early_hints.caddy
participant server as Caddy Server
npm->>make: postbuild → make caddy-generate-early-hints
make->>script: Execute with --html and --snippet paths
script->>html: Read and parse HTML
script->>script: Extract links & scripts,<br/>deduplicate resources
script->>caddy: Locate BEGIN/END markers
script->>caddy: Replace content with generated<br/>early_hint directives
caddy->>server: Caddy loads snippet on startup
server->>server: Apply early_hints matcher<br/>to eligible responses
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a script to generate Caddy Early Hints. However, the implementation is incorrect and will not produce Early Hints (103 responses) but rather Link headers on the final response due to improper use of Caddy directives. I've provided critical feedback on the generation script and the Caddy snippet to correct this. Additionally, there's a redundant command in the Dockerfile that should be removed to rely on the postbuild npm script.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
npm run buildand ships the snippet alongside the configTesting
Summary by CodeRabbit