The fastest HTTP request is the one that never needs to leave the browser. While server optimizations and content delivery networks (CDNs) are important, configuring browser caching headers properly is what enables sub-second page loads for returning visitors.
Understanding the Cache-Control Header
The `Cache-Control` response header tells the browser how long it may safely store a file locally before checking back with your server. For static assets that never change - such as versioned stylesheets, hashed scripts, and images-set an aggressive cache lifetime: `Cache-Control: public, max-age=31536000, immutable`
The `immutable` directive tells modern browsers that the file will never change during its valid lifetime, eliminating conditional revalidation requests entirely.
Managing HTML and Dynamic Endpoints
Unlike versioned CSS and JS files, dynamic HTML pages must never be cached indefinitely, or visitors will miss newly published content. For dynamic pages, use `Cache-Control: private, max-age=0, must-revalidate`. This instructs the browser to verify with the server using `ETag` or `Last-Modified` headers before displaying the cached page.
Developer handover checklist
- Keep source code in version control and document setup and configuration.
- Store secrets outside source code and restrict access to credentials.
- Test important business rules, validation, permissions, and failure paths.
- Log diagnostic details without exposing passwords, tokens, or personal data.
- Document deployment, rollback, backup, and recovery steps.
Verify before deployment
Test changed workflows in staging where possible. Check server logs, browser errors, response codes, and key user journeys after release. Measure the bottleneck before introducing complex optimisation.