Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#15564 closed (wontfix)

PROPOSAL: nocache template tag to exclude parts of a template from being cached

Reported by: izamojc@… Owned by: nobody
Component: Core (Cache system) Version: master
Severity: Keywords: template tag
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In many cases, I'd like to just be able to turn caching on for a project and let it do what it does automatically 99% of the time. However, most sites have authentication, and most display a "login or signup" message that gets replaced by the user's name when they sign in. This is problematic for caching since it means that same page will be cached multiple times, once for each user who views it, defeating the purpose of the cache.

I propose a formal {% nocache %} ... {% endnocache %} template tag that can be wrapped around these "micro-dynamic" regions of the template. This way, blanket caching can be applied to the entire site, and these cache-busting problem areas can be dealt with in a precise manner.

Change History (5)

comment:1 Changed 8 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

Yes, this would be nice to have... but then, so would a magical pony :-)

The use case you describe would clearly be useful, but I'm not sure I see how this could be implemented. Essentially you're asking for partially parsed template contents, where the template can be compiled, *except* for one tag that will be compiled at a later date. Implementing this sort of dual-compilation template *might* be possible, but it's not as simple as "just add a a nocache tag".

Closing wontfix for that reason. If you can provide a clear explanation of how this would actually be implemented (preferably with example code demonstrating the plausibility of your approach) feel free to reopen.

comment:2 Changed 8 years ago by izamojc@…

Resolution: wontfix
Status: closedreopened

comment:3 Changed 8 years ago by Jannis Leidel

For the record, Cody and me worked on a reusable app that implements the two-phase-rendering: (Code at

comment:4 Changed 8 years ago by Jannis Leidel

Resolution: wontfix
Status: reopenedclosed

Closing as wontfix again since this clearly needs discussion on django-developers.

comment:5 Changed 7 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

Note: See TracTickets for help on using tickets.
Back to Top