Can production build modules be long-term cached?
I noticed when running a build, the JS module filenames are hashed with a deterministic 5-character content hash. However, it seems like 5 characters would be too small to guarantee immutability. Is it still a good idea to add long-term cache headers to these modules, to something like 365 days / immutable?
@developit @ForsakenHarmony can comment better on this.
The 5 character hashes are 20 character hashes that have been truncated, similar to a "short hash" often used in Git. This is sufficient because hashes are designed to vary as much as possible in response to small changes in a message. While it's certainly possible to construct a case where hashes match while content does not, in practise the likelihood rounds to 0. This is furthered by the relatively small timeframe over which hashes have a chance to collide: the number of deploys pushed in a year that modify a given bundle.
FWIW I'm not opposed to slightly increasing the hash length (to 8?) if there's a way to demonstrate the need. Since there are a lot of folks who have been using the 5-character hashes without issue for a while, it seems like the change would need to be motivated either by anecdotal evidence or statistical likelihood.
TIL ^