Mkdocs: Cache Busting

Created on 9 Feb 2020  路  5Comments  路  Source: mkdocs/mkdocs

Is there any way to make mkdocs build the site with some hash string built into the names of the CSS and JS files to do some cache busting?

All 5 comments

No, not that I'm aware of. MkDocs only copies CSS and JS files without modification. Plugins don't even get access to those files.

What's the current common way of making sure the website and script assets aren't loaded from the cache?
I guess some hacky headers could do the trick but many host their docs on managed webspaces.

MkDocs is a static site generator. Static pages don't need to be concerned with such things. If you need this sort of thing, then perhaps MkDocs is not the right tool for you.

That is a bit of a silly non-answer. If your STATIC* website uses CSS or JS, being able to bust the cache is a useful thing.

A custom theme might have a small error that needs fixing, the JS might contain an API key (e.g. analytics) that might need updating. Waiting for the cache time to run out might not be feasible, neither is sending HTTP headers to direct the browser to not cache anything. Managed web spaces, which are a prime hosting solutions for static websites, might not even allow modified headers.

MkDocs doesn't support this, no.

Yes, in some cases you might be behind a cache, but they won't be setting far-future expiries.

GitHub pages is a good example that's got a fairly heavy caching policy, even then worst case is your page will be up to date in <60 seconds from deployment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

twardoch picture twardoch  路  3Comments

Kristinita picture Kristinita  路  3Comments

beeva-marcosromero picture beeva-marcosromero  路  4Comments

banj picture banj  路  6Comments

mikemadeja picture mikemadeja  路  6Comments