fastapi-simple-cachecontrol

Cache-Control header management for FastAPI

Overview

Provide middleware to control Cache-Control header.

Installation

This package is not registered in PyPI. Wheel is stored in GitHub Releases.

Usage

Adding header for all request

from fastapi import FastAPI
from fastapi_simple_cachecontrol.types import CacheControl
from fastapi_simple_cachecontrol.middleware import CacheControlMiddleware

app = FastAPI()
app.add_middleware(CacheControlMiddleware, cache_control=CacheControl("public"))

Specs

  • You can select only one of cacheability directives.
    • Supporting public, private, no-cache and no-store
  • Expires directives are used as value if only used public or private.

Refs