Performance: HTTP caching strategies
This affects how fast the browser can load resources by reusing previously fetched data, reducing network requests and server load.
Cache-Control: public, max-age=31536000, immutableCache-Control: no-cache
Expires: 0| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No caching (Cache-Control: no-cache) | N/A | N/A | Blocks rendering until network response | [X] Bad |
| Long max-age with immutable (Cache-Control: public, max-age=31536000, immutable) | N/A | N/A | Instant load from cache, no blocking | [OK] Good |
| Short max-age with stale-while-revalidate | N/A | N/A | Shows stale content immediately, updates in background | [!] OK |
export async function loader() {
return new Response('Hello', {
headers: { 'Cache-Control': 'max-age=10, stale-while-revalidate=30' }
});
}export async function loader() {
return new Response('Data', {
headers: { 'Cache-Control': 'max-age=abc' }
});
}Pass the test and this pattern moves unknown