I think that HTTP's ETag is exactly the mechanism for invalidating stale cached content. And digests are used for the same sake. Why are they better and why etags are not enough?
Because ETags still require the client to hit the server to see if the client's cached copy is still fresh. Rails puts a far future expires header on assets which means that the client will never hit the server again for an asset, it already has cached. Digests then become the means for the server to make a client get a new version of the asset. I think Rails used to use timestamps instead of digests, but digests have the added, small benefit that if you revert the asset back to its previous state, its digest will be the same, and the client may still have it cached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With