Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Full Documentation: http://readthedocs.org/docs/django-better-cache/en/latest/
Mailing List: https://groups.google.com/forum/#!forum/bettercache

## Better Cache

Better Cache is a replacement for the default cache template tag library from Django.
It is a better version of {% cache %}

What is better about Better Cache?

- Nested cache fragments inherit the variables their parent fragments key on
- Parent cache fragments can be given additional keys by their child cache fragments

An example:

{% cache 500 "outer" x %}
y = {{ y }}<br />
{% cache 500 "inner" y %}
x = {{ x }}<br />
{% endcache %}
{% endcache %}

In the default {% cache %} tag from Django, the inner fragment will not be
rerendered when x changes, because only the outer fragment uses that as a key
variable. The outer fragment will not update with y changes, because only the
inner fragment uses that.

With Better Cache, x and y affect both, so fragments will be re-rendered when
any important variable changes.

Better Cache also allows a syntax of giving defaults to key variables:

{% cache 500 "test" x=10 %}

### Controlling inheritence

You don't always want the outer cache fragments to invalidate when variables
only important to the inner fragment changes. In some cases, the inner fragment
is allowed to get stale if it stays cached longer as part of the parent, so
we want a way to disable the inheritence of the variables.

You can do this with the `local` modifier. All modifiers after the `local` will
affect only this cache fragment, not its parent.

{% cache 500 "outer" x %}
y = {{ y }}<br />
{% cache 500 "inner" local y %}
x = {{ x }}<br />
{% endcache %}
{% endcache %}

### Plans

- on-demand invalidation of fragments based on mappings through an ORM-like interface

Release files for bettercache 0.6-beta-1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bettercache 0.6-beta-1
File Size Uploaded
bettercache-0.6-beta-1.tar.gz 21.0 kB Details

Release files / bettercache-0.6-beta-1.tar.gz

Download URL bettercache-0.6-beta-1.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
046d959221c8616cff9d32aeed87d68d55992ae0a9531aaced8014cce275be94
BLAKE2b-256 checksum
How to use checksums
2f01d6f5a9bd1c8ba7d934a28d35d1475481a9accf05301d0a6f92b562b21e0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.7

1 release file

0.6.1

1 release file

0.6

1 release file

This release

0.6-beta-1 This release

1 release file

0.5.4

1 release file

0.5.1

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page