Problem
Some @cache argument combinations cannot cache anything, and they are accepted silently.
@cache() with no ttl and no directive: nothing is stored, and the response carries an empty Cache-Control: header.
GET /a -> {"n": 1} Cache-Control: ''
GET /a -> {"n": 2} Cache-Control: ''
@cache(no_store=True, ttl=60): the two arguments contradict each other.
Proposal
- Do not send an empty
Cache-Control header.
- At decoration time, warn (or raise
CacheXError) when the arguments leave nothing to cache or contradict each other, for example no_store together with ttl. The validation that already exists for stale / stale_ttl is the model to follow.
Problem
Some
@cacheargument combinations cannot cache anything, and they are accepted silently.@cache()with nottland no directive: nothing is stored, and the response carries an emptyCache-Control:header.@cache(no_store=True, ttl=60): the two arguments contradict each other.Proposal
Cache-Controlheader.CacheXError) when the arguments leave nothing to cache or contradict each other, for exampleno_storetogether withttl. The validation that already exists forstale/stale_ttlis the model to follow.