Capuchin
Capuchin

Reputation: 3775

Django caching: Fetching a queryset in context_processor

I have a queryset fetching specific notification objects for users to display in a custom context_processor. Now I'm wondering whether this could be a performance issue? If it is, can I somehow enable caching of data maybe 1 hour or 1 day from now on?

Should I do some custom caching or is django supported caching of objects enough?

Upvotes: 0

Views: 59

Answers (1)

Andrii Zarubin
Andrii Zarubin

Reputation: 2255

I will suggest you to use default cache and store a notification string itself (not an object). So you will be doing query once.

Another good solution will be using messages framework.

Upvotes: 1

Related Questions