Bird
0
0

If you want to disable caching for a specific user in a cached view, which approach is correct?

medium📝 Conceptual Q5 of 15
Django - Caching
If you want to disable caching for a specific user in a cached view, which approach is correct?
AUse a custom cache key that includes user ID
BRemove the @cache_page decorator
CSet timeout to zero in @cache_page
DUse @login_required decorator
Step-by-Step Solution
Solution:
  1. Step 1: Understand cache key customization

    To cache differently per user, the cache key must include user info.
  2. Step 2: Evaluate options

    Removing decorator disables caching for all users, timeout zero disables caching entirely, login_required controls access but not caching.
  3. Final Answer:

    Use a custom cache key that includes user ID -> Option A
  4. Quick Check:

    Custom cache keys control per-user caching [OK]
Quick Trick: Customize cache key to vary cache per user [OK]
Common Mistakes:
MISTAKES
  • Removing caching for all users instead of one
  • Misusing timeout=0 to disable caching per user
  • Confusing authentication with caching control

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes