Middleware that disables caching headers during development in Django.
In production you will typically a CDN or browser cache to speed up subsequent reads of your pages. This ensures reads don’t need to hit your DB as often.
from django.views.decorators.cache import cache_control
@method_decorator(cache_control(public=True, max_age=60 * 5)), name="dispatch")
def my_view(request):
...
However this is annoying during development as you always want to serve fresh pages and static files on page refresh. Using this middleware in development strips out the cache headers and prevents the browser (or dev cache) from caching your content.
Quickstart
Install Django disable cache headers:
pip install django-disable-cache-headers
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'disable_cache_headers.apps.DisableCacheHeadersConfig',
...
)
Add the middleware in your development settings, e.g in config/settings/local.py.
from .base import *
MIDDLEWARE += ["disable_cache_headers.middleware.DisableCacheControl"]
Running Tests
python -m venv venv
source ./venv/bin/activate
pip install -r requirements_test.txt
pytest
History
0.1.0 (2019-08-22)
First release on PyPI.
Metadata
Release files for django-disable-cache-headers 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-disable-cache-headers-0.0.1.tar.gz | 3.8 kB | Without provenance | Details for django-disable-cache-headers-0.0.1.tar.gz |
Release files / django-disable-cache-headers-0.0.1.tar.gz
| Download URL | django-disable-cache-headers-0.0.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b94e3d5ff4a9c2e599454c2ee8cf58e1dc65bd32b2c3e9fbdab83a923b8529e
|
|
BLAKE2b-256 checksum How to use checksums |
1e664a008c28e5e091c9dc24dbec7380f4b599831c727630c6426fc70f147ceb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8
|
Security for django-disable-cache-headers 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.