skillfed

Flask-Caching

Adds caching support to Flask applications.

flask-caching v2.4.1 10.1M downloads/30d#1,489 on PyPI934
Permissive license BSD-3-Clause Active released

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-caching

uv

uv add flask-caching

poetry

poetry add flask-caching

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python

Tags

flask caching decoratorcache flask viewsflask application cachehttp response caching flaskflask cache backendsmemoization flaskcache management flask
cachingperformance-optimizationflask-extension

More Dynamic Content packages