Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Integration between Django and the Varnish HTTP accelerator using the management port and telnet

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 varnishapp
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.py
README.rst

Django Varnish

Varnish is a state-of-the-art, high-performance HTTP accelerator. For more information checkout Varnish Site

Django Varnish works with Varnish server(s) to manage caching of object pages. It allows you to monitor certain models and when they are updated, Django Varnish will purge the model's absolute_url on your frontend(s). This ensures that object detail pages are served blazingly fast and are always up to date. You may also go in and manually tweak things (such as your VCL configuration) using a management command.

Setup

  1. Install the varnish python bindings
  2. Put django.contrib.humanize in your INSTALLED APPS.
  3. Put varnishapp in your INSTALLED_APPS then set a few more settings.
  4. Add (r'^admin/varnish/', include('varnishapp.urls')), to your urlconf before the other admin URLs.

Configure

VARNISH_WATCHED_MODELS is a list of installed models whose absolute_urls you want to purge from your Varnish cache upon saving. Example: ('auth.user','profiles.profile')

VARNISH_GLOBAL_WATCHED_MODELS is a list of installed models who will purge the entire Varnish cache upon saving. Example: ('auth.user','profiles.profile')

VARNISH_MANAGEMENT_ADDRS is a list of Varnish cache addresses (containing their management ports). Example ('server1:6082','server2:6082')

VARNISH_SECRET is the shared secret used to authenticate with Varnish server. Example 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

Management

You can view the status of your Varnish cache servers by going to /admin/varnish/ and being a superuser. Here is what it looks like in production.

Run the management command varnishmgt to blindly execute arguments to all Varnish backends. Example:

$ ./manage.py varnishmgt purge_url "/"
Something went wrong with that request. Please try again.