HTTP 缓存让浏览器和 CDN 复用一个响应,而不是重新获取它,由 Cache-Control 头控制。Web 应用的制胜模式是:给你的资源文件名加哈希并永久缓存它们;让 HTML 不可缓存。
两层策略
http
# Hashed, versioned assets — content never changes for a given URL
Cache-Control: public, max-age=31536000, immutable
# e.g. /static/app.9f2c1a.js (the hash changes when content changes)
# HTML — must always be fresh so it can point at new asset hashes
Cache-Control: no-cache
