Bug: must-revalidate cache-control makes entries to be cleaned from storage, while it's eTag could still be used for the If-None-Match header
edwinveldhuizen opened this issue · comments
What happened?
Currently the canStale is being used to clean up values in the storage.
For responses with the must-revalidate
cache-control it might however still be useful to keep, since even if it must be revalidated. a 304 from the api is also a valid revalidation and saves serving large responses.
axios-cache-interceptor version
v1.5.1
Node / Browser Version
node v20.12.2
Axios Version
v1.6.8
What storage is being used
Web Storage
Relevant debugging log output
Response:
next-web | response: {
next-web | status: 200,
next-web | statusText: 'OK',
next-web | headers: Object [AxiosHeaders] {
next-web | 'x-powered-by': 'Express',
next-web | 'x-request-id': 'ed59768054de4b97aa4ffa60584d0029',
next-web | 'cache-control': 'public, max-age=30, must-revalidate',
next-web | 'content-type': 'application/json; charset=utf-8',
next-web | etag: 'W/"119f-iOtK6EJt3aMPoTS7kNLoacukWGg"',
next-web | vary: 'Accept-Encoding',
next-web | date: 'Tue, 16 Apr 2024 11:31:24 GMT',
next-web | connection: 'keep-alive',
next-web | 'keep-alive': 'timeout=5',
next-web | 'transfer-encoding': 'chunked',
next-web | 'x-axios-cache-stale-if-error': '30000'
next-web | },
Call after expiration, no if-none-match
header:
api-local | "headers": {
api-local | "accept": "application/json",
api-local | "cache-control": "no-cache",
api-local | "pragma": "no-cache",
api-local | "expires": "0",
api-local | "user-agent": "axios/1.6.8",
api-local | "accept-encoding": "gzip, compress, deflate, br",
api-local | "host": "api-vp-local:6003",
api-local | "connection": "keep-alive"
api-local | },
api-local | "method": "GET",
Hey @edwinveldhuizen thanks for this bug report. Are you open to PR it? Make sure to add unit tests.
@arthurfiorette sure, but I’ll need some guidance in direction since you probably put this logic there for a reason.
It was originated from this pr: #507.
@arthurfiorette done, please let me know if you have any feedback