U
U
Undefined2021-12-18 21:47:27
Node.js
Undefined, 2021-12-18 21:47:27

How can you minify a hash for a filename?

Hello, for hashing files by the browser, I use the names of all files in the form of contenthash
But in this case, I get for example, 8e55fbb5e2f8a493.cssthat is, file names in hex, and not in letters, theoretically allowing more letters to be used for file names, I could reduce the number of characters in file name line. How can I safely convert hex to a mixture of letters, numbers and allowed characters for filenames that will make filenames shorter for different file systems and browsers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-12-18
@Undefined

The best way is name = version number , i.e. literally every file change increases the number by one (if you do not add a string file to the file name, then the numbering for the entire project will be the same), for this, at the file assembly stage, you will have to store and replace the real names with their numbers (in this file, store not only the name and number but also a hash, already long, use it to check the file change and initiate the issuance of the next number).
Also, the number can be packed into another number system with a base greater than 10 (by adding large small letters, as is done in base64)
In this case, the file name will not exceed 4-5 characters plus the extension (you can also get rid of it if the assembly prepares the config for the web server so that the statics return the correct content-type headers, but this, by the way, is often not required)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question