Recall & Review
beginner
What is template fragment caching in Django?
Template fragment caching stores parts of a template's rendered output to speed up page loading by reusing cached HTML instead of rendering it again.
Click to reveal answer
beginner
How do you mark a part of a Django template for fragment caching?
Use the {% cache %} template tag with a cache timeout and a cache key to wrap the part you want to cache.
Click to reveal answer
beginner
Example of using {% cache %} tag in Django template?
Example: {% cache 600 sidebar %} ... HTML for sidebar ... {% endcache %} caches the sidebar for 600 seconds.
Click to reveal answer
intermediate
Why use template fragment caching instead of full page caching?
Fragment caching lets you cache only slow or complex parts of a page, allowing dynamic parts to update without caching the whole page.
Click to reveal answer
intermediate
What happens if the cache key changes in template fragment caching?
If the cache key changes, Django treats it as a new cache entry and renders the fragment again, storing the new output.
Click to reveal answer
Which Django template tag is used for fragment caching?
✗ Incorrect
The {% cache %} tag is used to mark template fragments for caching.
What does the number in {% cache 300 key %} represent?
✗ Incorrect
The number 300 means the fragment is cached for 300 seconds (5 minutes).
If a cached fragment is expired, what does Django do?
✗ Incorrect
Django re-renders the fragment and stores the new output in cache.
Can template fragment caching improve performance when only part of a page is slow?
✗ Incorrect
Fragment caching targets slow parts to speed up page load without caching everything.
What must you do to use {% cache %} tag in your Django template?
✗ Incorrect
You must load the cache tag library in the template using {% load cache %} before using {% cache %}.
Explain how to implement template fragment caching in a Django template and why it helps performance.
Think about wrapping slow parts of your template with a special tag.
You got /4 concepts.
Describe what happens when a cached fragment expires and how Django handles it.
Consider what Django does when the cache is no longer valid.
You got /4 concepts.