cache.middleware

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Cache middleware — site-wide GET and explicit QUERY response caching.

Opt-in viacache_middleware_enabled = Truein config. Only caches GET requests that return stable 200 responses with no Set-Cookie header or per-request…

Cache middleware — site-wide GET and explicit QUERY response caching.

Opt-in viacache_middleware_enabled = Truein config. Only caches GET requests that return stable 200 responses with no Set-Cookie header or per-request nonce HTML. Requests carrying Cookie or Authorization bypass the cache entirely.

cache.middleware

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

_CachedResponse
class
CacheMiddleware
class

Site-wide cache for GET and explicitly opted-in QUERY 200 responses.

Skips caching for:

  • Non-GET requests
  • Requests with Cookie or Authorization headers
  • Non-200 responses
  • Responses with Set-Cookie header
  • HTML responses carrying a per-request nonce CSP
  • Streaming/SSE responses
_has_private_request_headers
function
def _has_private_request_headers(request: Request) -> bool

Return True for request headers that commonly vary per user.

Parameters

Name Type Default Description
request Request
_cacheable_response_headers
function
def _cacheable_response_headers(headers: tuple[tuple[str, str], ...]) -> tuple[tuple[str, str], ...]

Strip headers that the sender computes or that are hop-by-hop.

Parameters

Name Type Default Description
headers tuple[tuple[str, str], ...]

View source · /home/runner/work/chirp/chirp/site/../src/chirp/cache/middleware.py:1