

To my great pleasure, the post shot up to the first place in a few minutes and continued there for a full day, bringing just over 50,000 visitors to this blog, in total. Since it was interesting bit of code, I thought Hacker News would enjoy it, so I posted it there. Questions, Comments, Concerns:įeel free to open an issue here: github.A few days ago, I wrote a post about a peculiar piece of code that a friend of mine had sent me. It is free software, and may be redistributed under the terms specified in the LICENSE file. Licenseĭjango-cachebuster is Copyright (c) 2011, James Addison. The latest source code can always be found here: /jaddison/django-cachebuster Creditsĭjango-cachebuster is maintained by James Addison. Please feel free to send a pull request with fixes and in particular, additional detectors to improve the usefulness of this app.

Or if you wanted it to be a short busting string: from tectors import gitĬACHEBUSTER_UNIQUE_STRING = git.unique_string() Notes For example, in your settings.py: from tectors import gitĬACHEBUSTER_UNIQUE_STRING = git.unique_string() The hash is cached and used for subsequent cache-busting. git folder, and then extracts the current commit hash. It simply traverses the project’s path looking for the. To set it, you would mostly likely use a cachebuster detector at the moment, there is a single detector available for git. If CACHEBUSTER_UNIQUE_STRING is not set, the file’s last modified datetime will be used for cache-busting. Use the tags in your template files.ĬACHEBUSTER_UNIQUE_STRING: optional no default.

Python 2.6 (May work with prior versions, but untested - please report)ĭjango 1.2.x, 1.3.x (May work with prior versions, but untested - please report)Ĭopy or symlink the cachebuster package into your django project directory or install it by running one of the following commands:Īdd cachebuster to your INSTALLED_APPS in your project’s settings.py module. This app addresses this functionality gap.Īdditionally, there are some optimizations (see Advanced Settings below) that can be enabled to minimize file modification date disk reads. DescriptionĪll of the existing file cache busting techniques seem to be Django versions 1.2.x and lower oriented - meaning they don’t support the new paradigm. media is intended for user uploaded content like avatars, videos and other files.

static is meant for your site’s JavaScript, CSS and standard images. Each tag will use the file last modified timestamp by default to ‘bust’ web browser file caches. Django-cachebuster is a Django app containing two template tags: static and media.
