Browser & Web Performance · Junior · Question 42 of 75
Why do build tools put a content hash in file names like app.3f9a1c.js?
- 1To make the file smaller
- 2To prevent the file from being cached
- ✓Correct answer: So the file can be cached for a very long time; a change produces a new name and a new URL
Explanation
Hashed assets can use Cache-Control: max-age=31536000, immutable. The HTML that references them is cached briefly or revalidated.