Skip to main content

Beefier Cache-Control HTTP headers created by @never_cache decorator in Django.

Project description

django-beefycachecontrol is a Django middleware that smacks misbehaving upstream caches into submission with beefier anti-cache HTTP headers.

Normally, when a view is decorated with @never_cache:

@never_cache
def my_view(request):
    ...

The resulting HTTP headers (among other things) include:

Cache-Control       max-age=0

While this should be sufficient to prevent the response from being cached upstream, but there may be circumstances where this is not enough. Enter django-beefiercachecontrol!

With BeefyCacheControlMiddleware enabled, these HTTP headers become:

Cache-Control       max-age=0, no-cache, no-store

Cache that and you’d be arrested by the internet cops!

Installation

  1. easy_install django-beefycachecontrol or pip install django-beefycachecontrol

  2. Add beefycachecontrol to your INSTALLED_APPS

  3. In settings.py add 'beefycachecontrol.middleware.BeefyCacheControlMiddleware' to MIDDLEWARE_CLASSES

Usage

django-beefycachecontrol is a middleware. Once it is enabled, there is nothing more to do. It simply fixes up your no-cache related HTTP headers.

Project details


Download files

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

Source Distribution

django-beefycachecontrol-0.2.1.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file django-beefycachecontrol-0.2.1.tar.gz.

File metadata

File hashes

Hashes for django-beefycachecontrol-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b82750cdf9b667e96c641530deccc4769e5d42a6fa064e06d17385e370b57d4d
MD5 9f9c8f2a4810fa16aba5c1b3ca37d25f
BLAKE2b-256 c3af668c5388a07c427b3339a021000f8b8a25e9d454bda188856a135f5b6ed0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page