Skip to main content

Static file CDN cache buster for fast site updates.

Project description


django-cachekiller is a small add-on for Django that adds the cdnstatic template tag which adds a 'cache busting' dynamic query string appended to the file paths. This tag functions identically to the standard {% static ... %} template tag. This is designed to work with CDNs that cache by complete URI including the query string so when you push a change the CDNs are automatically refreshed without having to wait for TTLs to expire. Internally we use this with django-distill, a static site generator for Django to work with static sites with heavy caching on images behind CloudFlare, cachefly and other CDNs:

Under the hood, this module just chains the request to the existing static tag to be widely compatible.


Install from pip:

$ pip install django-cachekiller

Add django_cachekiller to your INSTALLED_APPS in your

    # ... other apps here ...

That's it.


Load the new module at the top of your templates:

{% load cdnstaticfiles %}

Then use the new tag in the template exactly as you would use the static tag:

{% cdnstatic 'some/image.jpg' %}

This renders as (assuming settings.STATIC_URL is set to /static/):

/static/some/image.jpg?tag=[random tag]

[random tag] is either the truncated mercurial or git commit reference if it is available, otherwise it will be the current date in YYYYMMDDHHMMSS format. If there are existing query string parameters then the tag is intelligently appended. The cdnstatic tag will not break the existing URL.


All properly formatted and sensible pull requests, issues and comments are welcome.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-cachekiller, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size django_cachekiller-0.6-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page