I’m always surprised when I go back to an old module and see how well engineered something is. In this case, I would like to cover fastify-etag.
ETags are a key part of the HTTP/1.1 caching mechanism https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
. ETags are hashes that are computed as part of a response, then then they are sent back for subsequent requests: in case the hash matches, it returns a 304 and no content.
The most important part for deploying ETags at scale is how fast it can compute those ETags. Using a cryptographic hashing algorithm like SHA1, SHA256 can significantly increase the CPU load of our Node.js processes.