Problem
CACHE_FLOW.md says that on a cache hit "the endpoint handler does not run at all". That holds for the function body, but:
- FastAPI dependencies are resolved before the
@cache wrapper, so they run on every request, hit or miss (expensive_dep ran 4 times for 4 requests). Per-user key builders rely on this, since they read request.state set by a dependency.
BackgroundTasks added in the handler run only on a miss.
People put DB sessions, audit logging or rate limiting in dependencies and background tasks, so both points matter.
Proposal
Add a short "What still runs on a hit" note to CACHE_FLOW.md and HTTP_CACHING.md (and zh-TW).
Problem
CACHE_FLOW.md says that on a cache hit "the endpoint handler does not run at all". That holds for the function body, but:
@cachewrapper, so they run on every request, hit or miss (expensive_dep ran 4 times for 4 requests). Per-user key builders rely on this, since they readrequest.stateset by a dependency.BackgroundTasksadded in the handler run only on a miss.People put DB sessions, audit logging or rate limiting in dependencies and background tasks, so both points matter.
Proposal
Add a short "What still runs on a hit" note to CACHE_FLOW.md and HTTP_CACHING.md (and zh-TW).