-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash our CSS/JS assets with digest
requests instead of in filenames
#376
Comments
digest
requestsdigest
requests instead of in filenames
Furo isn't using the digest headers -- it's putting the hash as |
@pradyunsg ah that is just me not really understanding what |
It's basically using the hash of the CSS file's contents for cache busting. A good link on cache busting would be https://css-tricks.com/strategies-for-cache-busting-css/. A good link on what "digest" means in this context would be https://developer.mozilla.org/en-US/docs/Glossary/Digest (although, we don't care about the integrity/security etc here -- just that it's a hash that changes when the contents change). SBT is already doing cache busting, by changing the filename and including a hash in it (computed during the pre-commit step). Furo is doing it in a slightly different way, by having a query parameter with the hash instead (computed during the Sphinx build). |
This is very helpful for me to understand, thanks for sharing those links 🙂 |
Summary
In #373 we learned that it is difficult to sub-theme this theme because of the hashes in the CSS / JS assets. @pradyunsg shared a solution that has worked for Furo, which uses Digest headers to specify a specific version of the JS/CSS assets. Here's the commit that added it in Furo:
pradyunsg/furo@11dc2ee
We could follow a similar pattern in this theme, which would make it easier for sub-themes to depend on it since they won't need to know the hash ahead of time, they can just specify a CSS file.
Implementation
We currently use a pre-commit hook to generate hashed CSS, JS, and a
theme.conf
file that addresses these hashed assets. Here's the asset compilation configuration for our pre-commit hook. Instead of specifying the hashes in filenames, we could create / append the hashes at Sphinx build time, following a similar pattern to what Furo does in the commit above.The text was updated successfully, but these errors were encountered: