Cache-Control ヘッダービルダーとは
The Cache-Control HTTP header tells browsers and CDNs how long to keep a resource before fetching a fresh copy. Setting it correctly improves page speed for repeat visitors and reduces unnecessary requests. Missing or overly aggressive cache headers are a common reason users see stale content after a deploy.
クイックアンサー
Use the Cache-Control HTTP header to tell browsers and CDNs how long to keep a resource before revalidating. For static sites: use public, max-age=31536000, immutable on fingerprinted CSS/JS, public, max-age=0, must-revalidate on HTML, and no-store on sensitive pages.
制限事項
- GitHub Pages does not support custom Cache-Control headers — only ETag and Last-Modified are provided automatically. Use Cloudflare or another CDN in front for custom caching rules.
- The immutable directive is not an official RFC standard but is widely supported by modern browsers and CDNs. Very old HTTP/1.1 proxies may ignore it.
- Browsers may still cache content when offline or in back-forward cache even when Cache-Control says no-store. Cache-Control is a hint, not a guarantee.
使い方
- Select the resource type that matches your content: static HTML, fingerprinted CSS/JS, images, feeds, private pages, or no-store.
- Choose your hosting platform for specific deployment tips if needed.
- Copy the Cache-Control header value and add it to your server config, CDN rules, or hosting platform headers file.
主な用途
- Set aggressive caching for fingerprinted CSS and JS files with content-hash filenames.
- Prevent caching of authentication pages, checkout flows, and sensitive user data.
- Configure feed and sitemap freshness so crawlers get up-to-date content without excessive requests.