In Chapter 7, Using NoSQL with Flask, we learned that page load time is one of the most important factors that will determine the success or failure of your web app. Despite the facts that our pages do not change very often, and that new posts will not be made very often, we still render the template and query the database every single time the page is asked for by our users' browsers.
Flask Caching solves this problem by allowing us to store the results of our view functions and return the stored results, rather than render the template again. First, we need to install Flask Caching on our virtual environment. This was already done when running the init.sh bash script. The init.sh script will first install all the declared dependencies in requirements.txt:
...
Flask-Caching
...
Next, initialize it in webapp/__init__.py as follows:
from flask_caching import Cache...