fastapi-cache-stable 0.3.0a1__tar.gz → 0.3.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_cache_stable-0.3.0b1/CHANGELOG.md +191 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/COMPATIBILITY.md +74 -26
- fastapi_cache_stable-0.3.0b1/MIGRATION.md +447 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/PKG-INFO +147 -18
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/README.md +145 -16
- fastapi_cache_stable-0.3.0b1/SECURITY.md +18 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/__init__.py +16 -2
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/backends/inmemory.py +18 -9
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/coder.py +51 -12
- fastapi_cache_stable-0.3.0b1/fastapi_cache/decorator.py +395 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/pyproject.toml +30 -3
- fastapi_cache_stable-0.3.0a1/CHANGELOG.md +0 -109
- fastapi_cache_stable-0.3.0a1/MIGRATION.md +0 -261
- fastapi_cache_stable-0.3.0a1/SECURITY.md +0 -15
- fastapi_cache_stable-0.3.0a1/fastapi_cache/decorator.py +0 -233
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/FORK_ORIGIN.md +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/LICENSE +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/NOTICE +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/SUPPORT.md +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/backends/__init__.py +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/backends/dynamodb.py +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/backends/memcached.py +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/backends/redis.py +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/key_builder.py +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/py.typed +0 -0
- {fastapi_cache_stable-0.3.0a1 → fastapi_cache_stable-0.3.0b1}/fastapi_cache/types.py +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# ChangeLog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the changes for the upcoming release can be found in <https://github.com/agustin18/fastapi-cache/tree/stable/changelog.d/>.
|
|
8
|
+
|
|
9
|
+
<!-- towncrier release notes start -->
|
|
10
|
+
|
|
11
|
+
## [0.3.0b1](https://github.com/agustin18/fastapi-cache/tree/v0.3.0b1) - 2026-11-16
|
|
12
|
+
|
|
13
|
+
### Bugfixes
|
|
14
|
+
|
|
15
|
+
- `FastAPICache.init()` now raises `RuntimeError` when called a second time instead of
|
|
16
|
+
silently keeping the first configuration. Call `FastAPICache.reset()` before
|
|
17
|
+
re-initializing, or pass the keyword-only `force=True` to replace the current configuration
|
|
18
|
+
explicitly. Applications that call `init()` from a lifespan handler must pass `force=True`
|
|
19
|
+
or reset first, because the handler runs on every startup. The bundled examples do this.
|
|
20
|
+
|
|
21
|
+
The decorator now resolves the coder and expiry per request instead of overwriting the
|
|
22
|
+
values captured at decoration time, so a re-initialization also applies to endpoints that
|
|
23
|
+
were already called. Reusing the same backend and namespace across coders can leave
|
|
24
|
+
entries in an incompatible format; flush or rotate the namespace when the coder changes. [#18](https://github.com/agustin18/fastapi-cache/issues/18)
|
|
25
|
+
|
|
26
|
+
### Improved Documentation
|
|
27
|
+
|
|
28
|
+
- Add GitHub issue forms for bug reports and feature requests, with a template chooser that
|
|
29
|
+
links to the support policy, migration guide, compatibility contract and private
|
|
30
|
+
vulnerability reporting. Blank issues are disabled so reports arrive with the information
|
|
31
|
+
needed to triage them.
|
|
32
|
+
|
|
33
|
+
Enable GitHub Issues for the repository and point every bug-reporting reference at a real
|
|
34
|
+
channel instead of "when issues are enabled". Security reports continue to use private
|
|
35
|
+
vulnerability reporting, never a public issue. The security response targets are now stated
|
|
36
|
+
as best-effort targets rather than contractual guarantees. [#20](https://github.com/agustin18/fastapi-cache/issues/20)
|
|
37
|
+
|
|
38
|
+
### Misc
|
|
39
|
+
|
|
40
|
+
- Remove the unused `tox.ini` and the `tox` development dependency. CI already runs the
|
|
41
|
+
supported matrix through GitHub Actions, and `CONTRIBUTING.md` documents `pip`, `pytest`,
|
|
42
|
+
Ruff and pre-commit instead of tox, so the tox file only declared a stale Python 3.7-3.11
|
|
43
|
+
matrix that no longer matched reality.
|
|
44
|
+
|
|
45
|
+
Add unit tests for the Memcached and DynamoDB backends using fake clients, and run them in a
|
|
46
|
+
new `optional-backends` CI job. They cover key encoding, get/set, TTL handling and the
|
|
47
|
+
unimplemented `clear`. Both backends remain Experimental: there are no integration tests
|
|
48
|
+
against a real service, and `MemcachedBackend.get_with_ttl()` still returns a fixed `3600`
|
|
49
|
+
instead of the real remaining time. [#19](https://github.com/agustin18/fastapi-cache/issues/19)
|
|
50
|
+
|
|
51
|
+
## [0.3.0a2](https://github.com/agustin18/fastapi-cache/tree/v0.3.0a2) - 2026-11-14
|
|
52
|
+
|
|
53
|
+
### Bugfixes
|
|
54
|
+
|
|
55
|
+
- Bypass the cache for requests with a non-empty `Authorization` or `Cookie` header by
|
|
56
|
+
default. Add `cache_authenticated=True` to opt in with an identity-aware `key_builder`;
|
|
57
|
+
opting in with the default key builder raises `ValueError` for authenticated requests.
|
|
58
|
+
Backend error logs now report only the endpoint, namespace, and exception type; they no
|
|
59
|
+
longer include the cache key, exception message, or traceback.
|
|
60
|
+
Clear or rotate the cache namespace when upgrading from versions that cached authenticated
|
|
61
|
+
responses. [#12](https://github.com/agustin18/fastapi-cache/issues/12)
|
|
62
|
+
- InMemory backend: `expire=None` now means no expiration instead of immediate expiry, and each
|
|
63
|
+
backend instance has its own store and lock. Existing process-local entries are not shared
|
|
64
|
+
between instances; use a shared backend for cross-process caching. [#13](https://github.com/agustin18/fastapi-cache/issues/13)
|
|
65
|
+
- Emit `Cache-Control: max-age` only when the effective expiry is valid and non-negative.
|
|
66
|
+
`expire=None` and no-expiration InMemory hits no longer produce `max-age=None` or
|
|
67
|
+
`max-age=-1`; `ETag` and the cache-status header are still emitted. `expire=0` keeps the
|
|
68
|
+
legacy fallback to the global `expire` value. [#14](https://github.com/agustin18/fastapi-cache/issues/14)
|
|
69
|
+
- Use a stable SHA-256 digest for the ETag and emit it as a quoted weak validator
|
|
70
|
+
(`W/"<digest>"`). `If-None-Match` now uses weak comparison, supports comma-separated lists
|
|
71
|
+
and `*`, and is evaluated on both cache hits and misses, including after
|
|
72
|
+
`Cache-Control: no-cache`. Malformed entity-tags are ignored. The ETag value changes once
|
|
73
|
+
when upgrading; clients revalidate and receive the new value. [#15](https://github.com/agustin18/fastapi-cache/issues/15)
|
|
74
|
+
- Namespace the internal `_spec_type` marker as `__fastapi_cache_spec_type__` so user payloads
|
|
75
|
+
with `_spec_type` are preserved. `JsonCoder` now caches only simple `JSONResponse` objects
|
|
76
|
+
(status `200`, `application/json`, no custom headers, no background task) and bypasses other
|
|
77
|
+
non-JSON responses (`StreamingResponse`, `FileResponse`, `RedirectResponse`, plain `Response`,
|
|
78
|
+
templates). Responses with `Set-Cookie`, `Cache-Control: no-store`/`private`, or a background
|
|
79
|
+
task are never cached, regardless of the coder. The injected `response` object is also
|
|
80
|
+
checked before a cache read and before writing; cookies, `Cache-Control: no-store`/`private`,
|
|
81
|
+
background tasks, non-`200` statuses, and custom headers bypass the cache. `PickleCoder` caches serializable response
|
|
82
|
+
objects it can reproduce faithfully and bypasses streaming, file, and template responses. Old
|
|
83
|
+
cache entries written with `_spec_type` are treated as user data; flush the namespace if you
|
|
84
|
+
cache `datetime`/`date`/`Decimal` values. [#16](https://github.com/agustin18/fastapi-cache/issues/16)
|
|
85
|
+
|
|
86
|
+
### Improved Documentation
|
|
87
|
+
|
|
88
|
+
- Document the published `0.3.0a1` release and pin the alpha install commands. [#11](https://github.com/agustin18/fastapi-cache/issues/11)
|
|
89
|
+
- Document the `0.3.0a2` release status, pin the alpha install commands, and record the tested
|
|
90
|
+
Redis/redis-py compatibility. The auth/privacy, InMemory, `Cache-Control`, ETag,
|
|
91
|
+
`_spec_type`, and response-bypass fixes are now available in `0.3.0a2`. [#17](https://github.com/agustin18/fastapi-cache/issues/17)
|
|
92
|
+
|
|
93
|
+
## [0.3.0a1](https://github.com/agustin18/fastapi-cache/tree/v0.3.0a1) - 2026-11-14
|
|
94
|
+
|
|
95
|
+
### Bugfixes
|
|
96
|
+
|
|
97
|
+
- Avoid caching explicitly returned `Response` objects with status codes >= 400. Adapted from upstream PR #575 by RitiGrover. [#2](https://github.com/agustin18/fastapi-cache/issues/2)
|
|
98
|
+
- Add opt-in `TypedJsonCoder` for Pydantic v2 typed restoration. `JsonCoder` keeps the legacy decoded behavior; Pydantic v1 and unsupported annotations fall back; validation errors propagate. Adapted from upstream PR #576 by bezff. [#4](https://github.com/agustin18/fastapi-cache/issues/4)
|
|
99
|
+
- Fix `clear(key=...)` so it deletes only the requested key, and require the `:` boundary for
|
|
100
|
+
namespace clears in InMemory and Redis. Redis standalone now uses `SCAN`/`UNLINK`; Redis
|
|
101
|
+
Cluster namespace clearing raises `NotImplementedError`. Memcached/DynamoDB clear remains
|
|
102
|
+
unsupported. [#7](https://github.com/agustin18/fastapi-cache/issues/7)
|
|
103
|
+
|
|
104
|
+
### Improved Documentation
|
|
105
|
+
|
|
106
|
+
- Document and verify the legacy compatibility matrix: Python 3.8/3.9, FastAPI 0.111.1, and
|
|
107
|
+
Pydantic 1.10.27/2.8.2. Add a legacy CI job and a Python 3.8 wheel smoke test. No runtime
|
|
108
|
+
behavior changes. [#5](https://github.com/agustin18/fastapi-cache/issues/5)
|
|
109
|
+
|
|
110
|
+
### Misc
|
|
111
|
+
|
|
112
|
+
- Bump the transitive `certifi` dev/test dependency from 2024.7.4 to 2026.10.23. [#6](https://github.com/agustin18/fastapi-cache/issues/6)
|
|
113
|
+
- Add a manual TestPyPI publishing workflow with a separate `testpypi` environment and Trusted Publisher. It never runs on `release: published`. [#8](https://github.com/agustin18/fastapi-cache/issues/8)
|
|
114
|
+
- Make PyPI publishing manual-only by removing the `release: published` trigger. [#9](https://github.com/agustin18/fastapi-cache/issues/9)
|
|
115
|
+
|
|
116
|
+
## 0.3.0a0
|
|
117
|
+
|
|
118
|
+
- Community-maintained stable fork of fastapi-cache2, based on v0.2.2.
|
|
119
|
+
- Distribution renamed to `fastapi-cache-stable`; the `fastapi_cache` import and public API are unchanged.
|
|
120
|
+
- Declare `jinja2` as a direct dependency; the `starlette.templating` import in `coder.py` requires it.
|
|
121
|
+
- This is an alpha to reserve the PyPI distribution name. The 0.3.0 release will include the P0 correctness fixes and compatibility tests.
|
|
122
|
+
|
|
123
|
+
## 0.2
|
|
124
|
+
|
|
125
|
+
### 0.2.1
|
|
126
|
+
- Fix picklecoder
|
|
127
|
+
- Fix connection failure transparency and add logging
|
|
128
|
+
- Add Cache-Control and ETag on first response
|
|
129
|
+
- Support Async RedisCluster client from redis-py
|
|
130
|
+
|
|
131
|
+
### 0.2.0
|
|
132
|
+
|
|
133
|
+
- Make `request` and `response` optional.
|
|
134
|
+
- Add typing info to the `cache` decorator.
|
|
135
|
+
- Support cache jinja2 template response.
|
|
136
|
+
- Support cache `JSONResponse`
|
|
137
|
+
- Add `py.typed` file and type hints
|
|
138
|
+
- Add TestCase
|
|
139
|
+
- Fix cache decorate sync function
|
|
140
|
+
- Transparently handle backend connection failures.
|
|
141
|
+
|
|
142
|
+
## 0.1
|
|
143
|
+
|
|
144
|
+
### 0.1.10
|
|
145
|
+
|
|
146
|
+
- Add `Cache-Control:no-cache` support.
|
|
147
|
+
|
|
148
|
+
### 0.1.9
|
|
149
|
+
|
|
150
|
+
- Replace `aioredis` with `redis-py`.
|
|
151
|
+
|
|
152
|
+
### 0.1.8
|
|
153
|
+
|
|
154
|
+
- Support `dynamodb` backend.
|
|
155
|
+
|
|
156
|
+
### 0.1.7
|
|
157
|
+
|
|
158
|
+
- Fix default json coder for datetime.
|
|
159
|
+
- Add `enable` param to `init`.
|
|
160
|
+
|
|
161
|
+
### 0.1.6
|
|
162
|
+
|
|
163
|
+
- Fix redis cache.
|
|
164
|
+
- Encode key builder.
|
|
165
|
+
|
|
166
|
+
### 0.1.5
|
|
167
|
+
|
|
168
|
+
- Fix setting expire for redis (#24)
|
|
169
|
+
- Update expire key
|
|
170
|
+
|
|
171
|
+
### 0.1.4
|
|
172
|
+
|
|
173
|
+
- Fix default expire for memcached. (#13)
|
|
174
|
+
- Update default key builder. (#12)
|
|
175
|
+
|
|
176
|
+
### 0.1.3
|
|
177
|
+
|
|
178
|
+
- Fix cache key builder.
|
|
179
|
+
|
|
180
|
+
### 0.1.2
|
|
181
|
+
|
|
182
|
+
- Add default config when init.
|
|
183
|
+
- Update JsonEncoder.
|
|
184
|
+
|
|
185
|
+
### 0.1.1
|
|
186
|
+
|
|
187
|
+
- Add in-memory support.
|
|
188
|
+
|
|
189
|
+
### 0.1.0
|
|
190
|
+
|
|
191
|
+
- First version release.
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
miss calls the endpoint, cache hit returns the cached value, and the cache status header
|
|
13
13
|
reports `MISS`/`HIT`.
|
|
14
14
|
- Existing `@cache(...)` and `FastAPICache.init(...)` calls keep working without code changes.
|
|
15
|
+
- Authenticated requests bypass the cache by default. This is an intentional privacy behavior
|
|
16
|
+
change; authenticated endpoints must opt in with `cache_authenticated=True` and an
|
|
17
|
+
identity-aware `key_builder` to keep caching.
|
|
18
|
+
- `InMemoryBackend` instances are isolated: each owns its store and lock. `expire=None` means
|
|
19
|
+
no expiration. InMemory remains process-local; use a shared backend for cross-process
|
|
20
|
+
caching.
|
|
15
21
|
- Existing custom backends, coders and key builders that implement the documented protocols
|
|
16
22
|
keep working.
|
|
17
23
|
- Migration from `fastapi-cache2` does not require application code changes for valid legacy
|
|
@@ -52,6 +58,7 @@ FastAPICache.init(
|
|
|
52
58
|
key_builder=default_key_builder,
|
|
53
59
|
cache_status_header="X-FastAPI-Cache",
|
|
54
60
|
enable=True,
|
|
61
|
+
cache_authenticated=False,
|
|
55
62
|
)
|
|
56
63
|
FastAPICache.clear(namespace=None, key=None)
|
|
57
64
|
FastAPICache.reset()
|
|
@@ -62,6 +69,7 @@ FastAPICache.get_coder()
|
|
|
62
69
|
FastAPICache.get_key_builder()
|
|
63
70
|
FastAPICache.get_cache_status_header()
|
|
64
71
|
FastAPICache.get_enable()
|
|
72
|
+
FastAPICache.get_cache_authenticated()
|
|
65
73
|
```
|
|
66
74
|
|
|
67
75
|
### `@cache(...)`
|
|
@@ -73,6 +81,7 @@ cache(
|
|
|
73
81
|
key_builder=None,
|
|
74
82
|
namespace="",
|
|
75
83
|
injected_dependency_namespace="__fastapi_cache",
|
|
84
|
+
cache_authenticated=None,
|
|
76
85
|
)
|
|
77
86
|
```
|
|
78
87
|
|
|
@@ -102,6 +111,7 @@ def __call__(
|
|
|
102
111
|
### `Coder` protocol
|
|
103
112
|
|
|
104
113
|
```python
|
|
114
|
+
classmethod can_encode(value) -> bool
|
|
105
115
|
classmethod encode(value) -> bytes
|
|
106
116
|
classmethod decode(value: bytes) -> Any
|
|
107
117
|
classmethod decode_as_type(value: bytes, *, type_) -> Any
|
|
@@ -145,12 +155,12 @@ Status definitions:
|
|
|
145
155
|
| `Response`/`JSONResponse` annotations | Legacy decoded behavior | No Pydantic schema generation; cache hits keep working |
|
|
146
156
|
| Redis standalone | Verified for clear semantics | Redis 7 service in CI with redis-py 4.6.0; key-only clear and namespace boundary tested. redis-py 5/6 are not supported by the current `^4.2.0rc1` constraint and are untested |
|
|
147
157
|
| Redis Cluster | Unsupported for namespace clear | Key-only clear is supported; namespace clear raises `NotImplementedError`; no complete namespace clearing |
|
|
148
|
-
| InMemory | Verified for basic operations
|
|
149
|
-
| Memcached | Experimental |
|
|
150
|
-
| DynamoDB | Experimental | `clear` raises `NotImplementedError`; the client cleanup issue remains open and is targeted for a future fix |
|
|
158
|
+
| InMemory | Verified for basic operations, clear semantics, `expire=None` and instance isolation | Unit tests; each instance owns its store and lock; no size cap yet |
|
|
159
|
+
| Memcached | Experimental | Unit tests with a fake client; `get_with_ttl` returns a fixed `3600` instead of the real remaining time; `clear` raises `NotImplementedError` |
|
|
160
|
+
| DynamoDB | Experimental | Unit tests with a fake client covering get/set, TTL and the expired-entry path; `clear` raises `NotImplementedError`; the client cleanup issue remains open and is targeted for a future fix |
|
|
151
161
|
| Import `fastapi_cache` | Verified | Covered by compatibility tests |
|
|
152
162
|
|
|
153
|
-
> Redis results in `0.3.
|
|
163
|
+
> Redis results in `0.3.0a2` cover Redis 7 with redis-py 4.6.0. Other client or server
|
|
154
164
|
> versions are not verified; do not infer support from the Redis 7 job alone.
|
|
155
165
|
|
|
156
166
|
### `0.3.0a1` status
|
|
@@ -158,9 +168,27 @@ Status definitions:
|
|
|
158
168
|
Implemented: error responses, opt-in `TypedJsonCoder`, `clear()` key/namespace semantics,
|
|
159
169
|
Redis Cluster namespace `NotImplementedError`, and the legacy compatibility matrix.
|
|
160
170
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
171
|
+
### `0.3.0a2` status
|
|
172
|
+
|
|
173
|
+
Implemented in `0.3.0a2`: authenticated requests bypass the
|
|
174
|
+
cache by default; opt-in with `cache_authenticated=True` and an identity-aware `key_builder`.
|
|
175
|
+
Opting in with the default key builder raises `ValueError` for authenticated requests.
|
|
176
|
+
`InMemoryBackend` instances are isolated, and `expire=None` means no expiration. The
|
|
177
|
+
decorator emits `Cache-Control: max-age` only for valid, non-negative expiry values; it
|
|
178
|
+
omits `max-age` for `expire=None` and no-expiration hits. `expire=0` keeps the legacy
|
|
179
|
+
fallback to the global `expire` value. ETags are quoted weak validators derived from a
|
|
180
|
+
stable SHA-256 digest; `If-None-Match` uses weak comparison, supports lists and `*`, is
|
|
181
|
+
evaluated on hits and misses, and ignores malformed entity-tags. `_spec_type` user payloads
|
|
182
|
+
are preserved via a namespaced internal marker. `JsonCoder` caches only simple `200`
|
|
183
|
+
`application/json` `JSONResponse` objects; other responses are bypassed unless the coder's
|
|
184
|
+
`can_encode` supports them. Responses with `Set-Cookie`, `Cache-Control: no-store/private`,
|
|
185
|
+
or a background task are never cached. The injected `response` object is checked before a
|
|
186
|
+
cache read and before a write; those directives, a non-`200` status, or any header other than
|
|
187
|
+
the automatic `content-length` bypass the cache for dict/list returns.
|
|
188
|
+
|
|
189
|
+
Merged on `stable`, ships in `0.3.0b1`: a second `FastAPICache.init()` call raises
|
|
190
|
+
`RuntimeError` unless you pass `force=True`. In the published `0.3.0a2` it is still a silent
|
|
191
|
+
no-op. Still targeted for later pre-releases: the Redis client/server matrix.
|
|
164
192
|
|
|
165
193
|
### Clear semantics
|
|
166
194
|
|
|
@@ -178,54 +206,74 @@ handling, explicit re-`init()`, and the Redis client/server matrix.
|
|
|
178
206
|
## Intentional behavior changes
|
|
179
207
|
|
|
180
208
|
These are bug fixes targeted for `0.3.0`. The error-response, typed-decode and
|
|
181
|
-
clear-semantics fixes are implemented in `0.3.0a1`; the
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
clear-semantics fixes are implemented in `0.3.0a1`; the auth/privacy, InMemory,
|
|
210
|
+
`Cache-Control`, ETag, `_spec_type` and response-caching fixes are implemented in `0.3.0a2`;
|
|
211
|
+
the second-`init` row is merged on `stable` and ships in `0.3.0b1`. Each one is documented in [`MIGRATION.md`](MIGRATION.md) and covered by a
|
|
212
|
+
regression test when implemented.
|
|
184
213
|
|
|
185
214
|
| Version | Change | Why | Status |
|
|
186
215
|
|---|---|---|---|
|
|
187
|
-
| 0.3.0 | Error `Response` objects (status >= 400) are not cached | A cached 404 could be returned as 200 | Implemented
|
|
188
|
-
| 0.3.0 | Opt-in `TypedJsonCoder` decodes cached JSON into the annotated return type on Pydantic v2 | Default `JsonCoder` and Pydantic v1 keep the legacy decoded behavior; `TypedJsonCoder` propagates validation errors | Implemented
|
|
189
|
-
| 0.3.0 | Authenticated requests bypass the cache by default | Prevent cross-user response reuse |
|
|
190
|
-
| 0.3.0 | ETag is stable across processes and correctly quoted | `hash()` is randomized per process and the old header was invalid |
|
|
191
|
-
| 0.3.0 | `clear(key=...)` deletes only that key | It used to delete the whole prefix namespace | Implemented
|
|
192
|
-
| 0.3.0 | `clear("app:user")` does not delete `app:users` | Namespace matching requires the `:` boundary | Implemented
|
|
193
|
-
| 0.3.0 | Redis Cluster namespace clear raises `NotImplementedError` | Partial/unsafe clearing was not reliable | Implemented
|
|
194
|
-
| 0.3.0 | `expire=None` means no expiration in `InMemoryBackend` | It used to expire almost immediately |
|
|
195
|
-
| 0.3.0 | `
|
|
196
|
-
| 0.3.0 |
|
|
197
|
-
| 0.3.0 |
|
|
198
|
-
| 0.3.0 |
|
|
216
|
+
| 0.3.0 | Error `Response` objects (status >= 400) are not cached | A cached 404 could be returned as 200 | Implemented in `0.3.0a1` |
|
|
217
|
+
| 0.3.0 | Opt-in `TypedJsonCoder` decodes cached JSON into the annotated return type on Pydantic v2 | Default `JsonCoder` and Pydantic v1 keep the legacy decoded behavior; `TypedJsonCoder` propagates validation errors | Implemented in `0.3.0a1` |
|
|
218
|
+
| 0.3.0 | Authenticated requests bypass the cache by default | Prevent cross-user response reuse | Implemented in `0.3.0a2` |
|
|
219
|
+
| 0.3.0 | ETag is stable across processes and correctly quoted | `hash()` is randomized per process and the old header was invalid | Implemented in `0.3.0a2` |
|
|
220
|
+
| 0.3.0 | `clear(key=...)` deletes only that key | It used to delete the whole prefix namespace | Implemented in `0.3.0a1` |
|
|
221
|
+
| 0.3.0 | `clear("app:user")` does not delete `app:users` | Namespace matching requires the `:` boundary | Implemented in `0.3.0a1` |
|
|
222
|
+
| 0.3.0 | Redis Cluster namespace clear raises `NotImplementedError` | Partial/unsafe clearing was not reliable | Implemented in `0.3.0a1` |
|
|
223
|
+
| 0.3.0 | `expire=None` means no expiration in `InMemoryBackend` | It used to expire almost immediately | Implemented in `0.3.0a2` |
|
|
224
|
+
| 0.3.0 | `InMemoryBackend` instances do not share state | The class-level store leaked entries between instances | Implemented in `0.3.0a2` |
|
|
225
|
+
| 0.3.0 | `Cache-Control` never emits `max-age=None` or `max-age=-1` | Invalid headers | Implemented in `0.3.0a2` |
|
|
226
|
+
| 0.3.0 | User payloads with a `_spec_type` key are not interpreted as internal metadata | The marker collided with user data | Implemented in `0.3.0a2` |
|
|
227
|
+
| 0.3.0 | Only simple `JSONResponse` objects are cached by `JsonCoder`; other responses bypass | Status/headers/body were lost or corrupted | Implemented in `0.3.0a2` |
|
|
228
|
+
| 0.3.0 | Responses with `Set-Cookie`, `Cache-Control: no-store/private`, or a background task are never cached | Cookies and private data could be replayed to other clients | Implemented in `0.3.0a2` |
|
|
229
|
+
| 0.3.0 | Injected `response` metadata is checked before cache reads and writes | Dict/list responses could cache cookies, private data, custom statuses, or custom headers | Implemented in `0.3.0a2` |
|
|
230
|
+
| 0.3.0 | A second `FastAPICache.init(...)` is not a silent no-op | Configuration was impossible to change | Merged on `stable`; ships in `0.3.0b1` |
|
|
199
231
|
|
|
200
232
|
## Cache data compatibility
|
|
201
233
|
|
|
202
|
-
- **ETag:** the value changes once.
|
|
234
|
+
- **ETag:** the value changes once. The new value is a stable SHA-256 digest; clients may
|
|
235
|
+
revalidate after upgrading.
|
|
203
236
|
- **Key format:** if a release changes the default key format, old entries become
|
|
204
237
|
unreachable. Flush the cache namespace after upgrading.
|
|
205
238
|
- **Error responses:** old cached error entries may remain until their TTL expires. Flush
|
|
206
239
|
the cache namespace if you were affected.
|
|
240
|
+
- **Authenticated responses:** entries written by versions that cached authenticated requests
|
|
241
|
+
under the default key may remain. Clear or rotate the cache namespace before deploying the
|
|
242
|
+
bypass, including all instances/workers and persistent Redis caches. The bypass is not
|
|
243
|
+
retroactive.
|
|
244
|
+
- **InMemory:** data is process-local and is lost on restart. Instances no longer share a
|
|
245
|
+
store; a new backend after `FastAPICache.reset()` starts empty. No data-format migration.
|
|
207
246
|
- **Pydantic/dataclass values:** old entries encoded as plain JSON still decode; the
|
|
208
247
|
annotated type is restored on read. No flush required for this fix alone.
|
|
248
|
+
- **`_spec_type`:** the internal marker changed to `__fastapi_cache_spec_type__`. Old entries
|
|
249
|
+
written with `_spec_type` are treated as user data; flush the namespace if you cache
|
|
250
|
+
`datetime`/`date`/`Decimal` values.
|
|
209
251
|
|
|
210
252
|
## How compatibility is tested
|
|
211
253
|
|
|
212
254
|
- API signature tests for the public names above.
|
|
213
255
|
- Characterization tests for the normal GET success path.
|
|
256
|
+
- Auth/privacy tests for default bypass, opt-in isolation, backend non-access, and legacy
|
|
257
|
+
cache-entry invalidation.
|
|
258
|
+
- InMemory tests for `expire=None`, instance isolation, clear isolation, and decorator
|
|
259
|
+
default-expire behavior.
|
|
214
260
|
- Regression tests for every behavior change.
|
|
215
261
|
- CI tests Python 3.10–3.13 with resolver-selected FastAPI and Pydantic versions.
|
|
216
262
|
- A `legacy-compat` job tests Python 3.8/3.9 with FastAPI 0.111.1 and Pydantic 1.10.27/2.8.2,
|
|
217
263
|
plus Python 3.10/3.11 with Pydantic 1.10.27.
|
|
218
264
|
- A `legacy-smoke` job builds the wheel and installs it on Python 3.8 with Pydantic 1.10.27.
|
|
219
265
|
- Wheel and sdist smoke tests in a clean virtual environment.
|
|
220
|
-
- Redis 7 integration tests run in CI
|
|
221
|
-
|
|
266
|
+
- Redis 7 integration tests run in CI.
|
|
267
|
+
- Memcached and DynamoDB have unit tests with fake clients in CI (`optional-backends` job).
|
|
268
|
+
They cover key encoding, get/set, TTL handling and the unimplemented `clear`. They do not
|
|
269
|
+
use a real service, so both backends stay Experimental.
|
|
222
270
|
- Migration tests that install the package and run a small app.
|
|
223
271
|
|
|
224
272
|
## If we break something
|
|
225
273
|
|
|
226
274
|
We treat a compatibility break as a bug:
|
|
227
275
|
|
|
228
|
-
1. Open an issue
|
|
276
|
+
1. Open an issue with the bug report form, or use private vulnerability reporting for a
|
|
229
277
|
vulnerability.
|
|
230
278
|
2. Document the break and the rollback path in `MIGRATION.md`.
|
|
231
279
|
3. Publish a patch release with a regression test.
|