Skip to content
Django per-model cache purging
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Roan is a per-model url purging Django app. It connects to model signals and purge URLs wherever a model is saved, updated or deleted.

Getting started


You can install Roan using pip:

$ [sudo] pip install roan

The only dependency is requests, that will be installed automatically by pip (if you don't use the --no-deps argument).


Roan uses only an optional setting: ROAN_PURGE_URL. If you don't specify it, it'll be http://localhost/purge.

Example of configuration:


nginx proxy_cache support

Since Roan is based on a personal need, it's based on nginx's proxy_cache.

Suppose you have the following purge mapping:

location ~ /purge(/.*) {
    deny all;
    proxy_cache_purge roan "$scheme://$host$1";

Now suppose you have the following Django model:

class Post(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()

And you have a URL /posts where users can see a list of posts. How can you set a forever cache and expect the cache to be refreshed whenever a new post is saved? Or whenever a post gets updated or deleted?

Using Roan you'll be able to connect one or more models to one or more URL. So you can connect the Post model with the /posts URL, and whenever a Post gets saved, updated or deleted, Roan makes a request to the /purge/posts URL.


Once you have Roan installed and configured, you just need to call it in a file that Django executes (e.g.: the of your app). Here is the code for the example above, of purging the /posts URL whenever a post gets saved or deleted:

from roan import purge
from models import Post



Pull requests are very welcome! Make sure your patches are well tested.

setting up the development environment

To setup the development environment, just run:

$ make bootstrap

This command will install all the development dependencies. It assumes you're using virtualenv and don't use sudo to install the dependencies. If you want to use the Python of your system, use sudo to run the make bootstrap command.

running the test suite

make is also used to run the tests of the application:

$ make test
Something went wrong with that request. Please try again.