Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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: UI/UX:

Description

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.

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 3 years ago by izamojc@…

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:3 Changed 3 years ago by jezdez

For the record, Cody and me worked on a reusable app that implements the two-phase-rendering: http://pypi.python.org/pypi/django-phased (Code at https://github.com/codysoyland/django-phased)

comment:4 Changed 3 years ago by jezdez

  • Resolution set to wontfix
  • Status changed from reopened to closed

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

comment:5 Changed 3 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.