System Design · Middle · Question 9 of 75
How should JS and CSS bundles be cached?
- ✓Correct answer: A hash in the filename and
Cache-Control: max-age=31536000, immutable - 2
Cache-Control: no-storeso the user always gets fresh code - 3Time-based:
max-age=3600for all files
Explanation
The name app.3f9a1c.js changes when the content changes, so the file can be cached "forever". The HTML that references the bundles is cached briefly or with revalidation, so a new release is picked up immediately. Bundlers do the hashing automatically.