django-cachepurge

Software Screenshot:
django-cachepurge
Software Details:
Version: 0.3
Upload Date: 11 May 15
Developer: Bertrand Mathieu
Distribution Type: Freeware
Downloads: 0

Rating: 1.0/5 (Total Votes: 1)

django-cachepurge allows Django to purge HTTP cache when a model instance is changed or deleted. It does this by sending "PURGE" requests to one or more upstream HTTP cache (such as Squid or Varnish). This is inspired by Plone CacheFu components.

Usage

In settings.py put 'django_cachepurge' before any other application; else it may failt to register some models:

INSTALLED_APPS = (
 'django_cachepurge',
 ...
)


Add the middleware:

MIDDLEWARE_CLASSES = (
 ...
 'django_cachepurge.middleware.CachePurge',
)


Define CACHE_URLS:

CACHE_URLS = 'http://127.0.0.1:3128'

or if you have more than one cache:

CACHE_URLS = ('http://127.0.0.1:3128',
 'http://192.168.1.42:3128')


Models

Urls are extracted from models instances on post_save signal. Two sources are used:

* instance.get_absolute_url(), if it exists
* instance.get_purge_urls(), if it exists. The application expects a list of absolute paths similar to what is provided by get_absolute_url().

Purge request is sent when response has been computed: if an exception occurs the urls are not purged. Purge requests are asynchronous: worker threads handle that so that we don't have wait to complete all requests before returning the response.

What is new in this release:

  • Compatible with Django 1.3: don't import django.utils.thread_support
  • catch NoReverseMatch exception when trying to find an instance's url

What is new in version 0.2:

  • Accept to purge only site urls, converted if needed into their relative form (i.e, "/some/path/")

Requirements:

  • Python
  • Django

Comments to django-cachepurge

Comments not found
Add Comment
Turn on images!