Recall & Review
beginner
What is Flask-Caching used for in a Flask application?
Flask-Caching is used to store the results of expensive or slow operations so that future requests can get the response faster without repeating the work.
Click to reveal answer
beginner
How do you initialize Flask-Caching in a Flask app?
You create a Cache object with your Flask app and a configuration, like this: <br><code>from flask_caching import Cache<br>cache = Cache(app, config={'CACHE_TYPE': 'simple'})</code>Click to reveal answer
beginner
What does the @cache.cached(timeout=60) decorator do on a Flask route?
It saves the response of that route for 60 seconds. During that time, repeated requests return the saved response quickly without running the route code again.
Click to reveal answer
intermediate
Name two cache types supported by Flask-Caching.
Two common cache types are 'simple' (in-memory cache for development) and 'redis' (using Redis server for production caching).
Click to reveal answer
beginner
Why is caching useful in web applications?
Caching reduces server work and speeds up response times by reusing previous results. This helps handle more users and improves user experience.
Click to reveal answer
What does the 'timeout' parameter in @cache.cached(timeout=30) control?
✗ Incorrect
The 'timeout' sets how many seconds the cached response stays valid before the cache is refreshed.
Which Flask-Caching cache type is best for simple development testing?
✗ Incorrect
'simple' cache stores data in memory and is easy to use for development.
How do you apply caching to a Flask route function?
✗ Incorrect
The @cache.cached decorator wraps the route to cache its output.
What happens if you do not use caching on a slow route?
✗ Incorrect
Without caching, each request triggers the slow operation again.
Which of these is NOT a benefit of using Flask-Caching?
✗ Incorrect
Caching improves speed and load but does not fix bugs automatically.
Explain how to add caching to a Flask route using Flask-Caching.
Think about setup, decorator, and timeout.
You got /4 concepts.
Describe why caching responses in a web app can improve user experience.
Focus on speed and server work.
You got /4 concepts.