Skip to main content

A simple Django app that provides a per-request cache.

Project description

Django Request Cache provides a cache for each request (within your Django Request/Response cycle).

Quick start

  1. Download and install using pip install
pip install django-request-cache
  1. Add UserForeignKeyMiddleware and RequestCacheMiddleware to your MIDDLEWARE settings like this:

or if you are still using the an older Django version (e.g., Django 1.8) with MIDDLEWARE_CLASSES:

  1. Use the per-request cache as a decorator
from django_request_cache import cache_for_request

def do_some_complex_calculation(a, b, c):
    print("Calculating... please wait")
    return a * b * c

Try it out by executing do_some_complex_calculation multiple times within your request


RequestCache and RequestCacheMiddleware (see are from a source code snippet on StackOverflow created by coredumperror Original Question was posted by at copied on 2017-Dec-20

Download files

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

Files for django-request-cache, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size django_request_cache-1.2-py2.py3-none-any.whl (4.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-request-cache-1.2.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page