kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Add hashing to font CSS and WOFF generation steps

Open rtibbles opened this issue 4 years ago • 0 comments

Observed behavior

Currently the CSS files and WOFF files generated by our fonts.py utility does not add any kind of version information to the file names. This makes determining appropriate caching for these files difficult.

Expected behavior

The files should be generated in a way that includes the 32 digit hex checksum as part of the filename for both the CSS and WOFF files.

Preferably this should be done as: [originalFilename]-[hash].[extension]

References to the font filenames inside the CSS files should then have this updated name.

In addition, we will need to store a register of these hashed file names somewhere for the Kolibri Python code to reference, in order to know the name of the file. The simplest option would be to store them in a .json file somewhere with a simple map from the original filename to the hashed filename. This can then be read by Kolibri at runtime to look up the appropriate filename.

This strategy is similar to the strategy used by the Django ManifestStaticFiles storage class, but we are doing this at build time instead of runtime, and because these files are only updated relatively infrequently.

User-facing consequences

Font files may not be cached as much as they could, which would lead to requesting large files more often.

Follow up from #7797

rtibbles avatar Feb 19 '21 20:02 rtibbles