July 2018
Intermediate to advanced
354 pages
8h 51m
English
A popular technique to make updating assets easier with long time to live values is using hash values in the file name. This is because a hash which is generated based on the file's contents means that the algorithm generates a relatively unique value.
The unique name creates a new URL for the asset and assigns a new Cache-Control value to the asset. This works well with style sheets, scripts and images, and other static resources.
MD5 hash values are the most common way to create these unique values. Node.js has a built-in crypto module with MD5 hash capabilities:
function getHash(data) {
var md5 = crypto.createHash('md5');
md5.update(data);
return md5.digest('hex');
}
The data parameter is ...
Read now
Unlock full access