HTTP caching browsers اور CDNs کو ایک response کو دوبارہ fetch کرنے کے بجائے دوبارہ استعمال کرنے دیتی ہے، جسے Cache-Control header control کرتا ہے۔ web apps کے لیے کامیاب pattern: اپنے asset filenames کو hash کریں اور انہیں ہمیشہ کے لیے cache کریں؛ HTML کو غیر قابلِ cache رکھیں۔
دو درجوں کی strategy
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
