How does Django's caching framework work, and what are the trade-offs between Per-View caching and Template Fragment caching?

Last updated 17 June 2026

  • Configure a pluggable backend in CACHES (Redis, Memcached, DB, local memory) and cache at site, view, fragment or low-level object granularity.

  • Per-view @cache_page caches the whole response by URL, skipping view and DB work entirely. It's all-or-nothing, so it's wrong for per-user or dynamic pages.

  • Fragment caching ({% cache %}) caches only expensive blocks and keeps the rest live, but the view still runs. Use it for dynamic pages with a few heavy parts.

  • https://www.interviewbit.com/django-interview-questions/
  • https://www.scribd.com/document/911648753/Headout-Backend-Engineering-Interview-Questions-Bank-CLAUDE
  • https://www.uplers.com/
  • https://medium.com/@anas-issath/the-django-career-guide-from-junior-to-senior-fea1c3e52aa6
  • https://www.quora.com/What-are-some-interview-questions-asked-or-can-be-asked-related-to-Django-and-Python
  • https://www.reddit.com/r/developersIndia/
  • https://internshala.com/blog/infosys-python-interview-questions/
All Django interview questions