HTTP caching ช่วยให้เบราว์เซอร์และ CDN นำ response กลับมาใช้ซ้ำได้แทนที่จะ fetch ใหม่ ควบคุมด้วย header Cache-Control รูปแบบที่ชนะสำหรับเว็บแอป: ใส่ hash ในชื่อไฟล์ asset แล้ว cache มันตลอดกาล; ส่วน HTML ให้ cache ไม่ได้
กลยุทธ์สองชั้น
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
