Per-View and Per-Site Caching
Cache whole pages with decorators.
Cache the Whole Page
Sometimes a full page is expensive to build. Django can store the entire rendered response and replay it for the next visitor.
The cache_page Decorator
Wrap a view in cache_page and Django caches its full output for the number of seconds you pass in.
from django.views.decorators.cache import cache_page
@cache_page(60 * 15)
def article_list(request):
...All lessons in this course
- Cache Backends and Redis
- Per-View and Per-Site Caching
- Template Fragment Caching
- Low-Level cache API and Invalidation