Flask-Caching
Adds caching support to Flask applications.
What it is and what it does
Flask-Caching is a community-maintained fork of Flask-Cache that provides a decorator-based caching layer for Flask applications. It sits between your Flask routes and view logic, allowing you to cache expensive computations, database queries, or entire HTTP responses with minimal code changes. The package abstracts away the complexity of managing different cache backends—you configure a backend (simple in-memory, Redis, Memcached, filesystem, or others) once, then use decorators to mark functions for caching.
The package depends only on flask and cachelib, keeping the install footprint small. It's actively maintained by the Pallets Community Ecosystem (the organization behind Flask itself), with recent releases and no known security vulnerabilities. It supports current Python versions (3.10+) and is classified as production-stable.
Use it for:
- Cache expensive database queries in view functions to reduce load and improve response times.
- Cache rendered templates or partial HTML fragments to avoid re-rendering on every request.
- Memoize the results of slow computations or API calls with automatic expiration.
- Implement request-level or application-level caching strategies without writing backend-specific code.
- Add cache invalidation logic to clear cached data when underlying data changes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask-Caching adds caching support to Flask applications, allowing you to cache view functions, templates, and arbitrary data using multiple backend storage options.
Yes. Flask-Caching is a mature, actively maintained package with low install friction, no security issues, and a permissive license. It's the standard way to add caching to Flask applications and is backed by the Pallets organization. Install it if you need to cache view functions, templates, or arbitrary data in a Flask app.
Install
flask-caching on PyPI
pip
pip install flask-cachinguv
uv add flask-cachingpoetry
poetry add flask-cachingInstalling Flask-Caching
Before you install
Low friction install with only two runtime dependencies (flask and cachelib). The project is actively maintained under the Pallets Community Ecosystem with a recent release and ongoing repository activity.
License in practice
BSD-3-Clause is a permissive license; you can use this package freely in commercial and private projects with minimal restrictions, provided you include the license text.
Quickstart
pip install flask-caching
from flask import Flask
from flask_caching import Cache
app = Flask(__name__)
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
@app.route('/data')
@cache.cached()
def get_data():
return {'result': 'cached'}
Requires Python 3.10 or later.
Verify before relying
- Whether all advertised cache backends (Redis, Memcached, filesystem, etc.) are included or require separate installation.
- Performance characteristics and cache hit/miss overhead compared to direct backend usage.
- Default cache timeout values and expiration behavior for decorated functions.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — flask, cachelib |
| Maintenance | actively maintained — 37 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,050,421/month — #1,489 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_caching-2.4.1-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
Flask-AdminFlask-Admin adds a customizable admin interface…
permissive · top 5,000 on PyPI
Flask-MailFlask-Mail adds email-sending functionality to…
permissive · top 5,000 on PyPI
Flask-SecurityFlask-Security adds authentication,…
permissive · top 15,000 on PyPI
cachelibCacheLib provides a unified API for interacting…
permissive · top 5,000 on PyPI
Flask-SessionFlask-Session adds server-side session storage…
permissive · top 5,000 on PyPI
Pallets-Sphinx-ThemesProvides Sphinx themes styled for Pallets…
permissive · top 15,000 on PyPI
Flask-PydanticAdds Pydantic model validation to Flask route…
permissive · top 15,000 on PyPI
Flask-APIFlask-API adds browsable web interfaces and…
permissive · top 15,000 on PyPI
Flask-CompressFlask-Compress automatically compresses Flask…
permissive · top 5,000 on PyPI
Flask-InjectorIntegrates dependency injection into Flask…
permissive · top 15,000 on PyPI