Skip to content

A lightweight flask extension that cache-busts static files by adding content-based query parameters to their URLs

License

Notifications You must be signed in to change notification settings

daxlab/Flask-Cache-Buster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-Cache-Buster is a lightweight Flask extension that adds a hash to the URL query parameters of each static file. This lets you safely declare your static resources as indefinitely cacheable because they automatically get new URLs when their contents change.

Usage

from flask_cache_buster import CacheBuster

config = {
     'extensions': ['.js', '.css', '.csv'],
     'hash_size': 10
}

cache_buster = CacheBuster(config=config)
cache_buster.register_cache_buster(app)

The url_for function will now cache-bust your static files. For example, this template:

<script src="{{ url_for('static', filename='js/main.js') }}"></script>

will render like this:

<script src="/static/js/main.js?%3Fq%3Dc5b5b2fa19"></script>

License

MIT

TODO

  • python 2.7 support
  • add tests

Inspired by ChrisTM/Flask-CacheBust

About

A lightweight flask extension that cache-busts static files by adding content-based query parameters to their URLs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages