Recall & Review
beginner
What is cache invalidation in Django?
Cache invalidation is the process of removing or updating cached data when the original data changes, ensuring users see fresh and accurate information.
Click to reveal answer
beginner
Name three common cache invalidation strategies used in Django.
1. Time-based expiration (TTL)<br>2. Manual cache clearing<br>3. Event-driven invalidation (e.g., signals)
Click to reveal answer
beginner
How does time-based expiration (TTL) work in Django caching?
You set a time-to-live (TTL) for cached data. After this time passes, the cache automatically expires and is removed or refreshed on next access.
Click to reveal answer
intermediate
What role do Django signals play in cache invalidation?
Django signals can trigger cache clearing or updating when certain events happen, like saving or deleting a model, ensuring cache stays in sync with the database.
Click to reveal answer
intermediate
Why is manual cache clearing sometimes necessary in Django?
Because some data changes are complex or unpredictable, manual clearing lets developers explicitly remove or update cache to avoid showing stale data.
Click to reveal answer
Which cache invalidation strategy automatically removes cached data after a set time?
✗ Incorrect
Time-based expiration uses a TTL to automatically expire cached data after a set period.
What Django feature can trigger cache invalidation when a model instance is saved?
✗ Incorrect
Django signals can listen for model save events and trigger cache invalidation.
Why might you manually clear cache in Django?
✗ Incorrect
Manual clearing is used when automatic invalidation does not cover all data changes.
Which of these is NOT a cache invalidation strategy?
✗ Incorrect
Database indexing improves query speed but is unrelated to cache invalidation.
What happens if cache invalidation is not done properly in Django?
✗ Incorrect
Without proper invalidation, cached data can become stale, showing users outdated information.
Explain the main cache invalidation strategies in Django and when you might use each.
Think about automatic vs manual ways to keep cache fresh.
You got /4 concepts.
Describe how Django signals can help keep cached data up to date.
Focus on event-driven cache updates.
You got /3 concepts.