Found during the docs audit (#361).
_build_cache_control returns "" when no directive is set, and _with_cache_control (fastapi_cachex/cache.py:1145) sets the header anyway, so a plain @cache() answers with an empty header:
@app.get("/e")
@cache()
async def e(): ...
# response.headers["cache-control"] == ""
An empty Cache-Control is valid to ignore but useless, and it replaces any Cache-Control the handler set itself. Expected: omit the header when there are no directives (and keep the handler's own header, if the current code would otherwise overwrite it; check which applies). Add a test.
Found during the docs audit (#361).
_build_cache_controlreturns""when no directive is set, and_with_cache_control(fastapi_cachex/cache.py:1145) sets the header anyway, so a plain@cache()answers with an empty header:An empty
Cache-Controlis valid to ignore but useless, and it replaces anyCache-Controlthe handler set itself. Expected: omit the header when there are no directives (and keep the handler's own header, if the current code would otherwise overwrite it; check which applies). Add a test.