Skip to main content

flask-cachebuster

Flask-CacheBuster is a lightweight http://flask.pocoo.org/ 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.

Notes:

Inspired by https://github.com/ChrisTM/Flask-CacheBust, and an updated version of https://github.com/daxlab/Flask-Cache-Buster to work with python 3.+

Installation

Using pip:

pip install flask-cachebuster

Usage

Configuration:

from flask_cachebuster import CacheBuster

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

cache_buster = CacheBuster(config=config)

cache_buster.init_app(app)

Configuration

Configuration:

* extensions - file extensions to bust
* hash_size - looks something like this `/static/index.css%3Fq3` where [%3Fq3] is the hash size.

The http://flask.pocoo.org/docs/0.12/api/#flask.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>

Release files for Flask-CacheBuster 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-CacheBuster 1.0.0
File Size Uploaded
Flask-CacheBuster-1.0.0.tar.gz 3.1 kB Details

Release files / Flask-CacheBuster-1.0.0.tar.gz

Download URL Flask-CacheBuster-1.0.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c8d7b57db8953f5c5875153f16cb970c2ed5a681b39326613c822f0c9764ec8
BLAKE2b-256 checksum
How to use checksums
7447f3e1fedfaad965c81c2f17234636d72f71450f1b4522ca26d2b7eb4a0a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page