Open JustinTRoss opened 2 years ago
Hi @JustinTRoss, you're right this is confusing. The TTL of the error cache must always be longer than the default TTL cache.
maxTtlIfError
defines the exact duration in seconds of the error cache. We should update docs with this, for example:
maxTtl: 60 // cache requests for 1min
maxTtlIfError: 60 // cache for another 1min when the revalidation requests result in an error.
Got it. To confirm:
requestCache: {
maxTtl: 10 * 60, // 10min, will respond for 10min with the result in cache (revalidated every 10min)
maxTtlIfError: 30 * 60, // 30min, will respond with the result in cache for a further 30 minutes when revalidation attempts result in error (40 minutes total)
},
yes, (40 minutes total)
is confusing. I'd remove it.
Agreed. It could be better worded. It sounds like the sentiment is generally true though, that the cached value can be returned for up to 40 minutes. This seems necessary for folks to understand. I'll work on conveying it clearly and send a PR with updated docs.
Thanks again! 🙏
Thanks!
This line makes it appear
maxTtlIfError
is whatever value is provided in seconds formaxTtlIfError
https://github.com/StarpTech/apollo-datasource-http/blob/5f0036f6510790e42c5ecf36900367bb6400514f/README.md?plain=1#L113This line makes it appear as though
maxTtlIfError
actually ends up beingmaxTtl + maxTtlIfError
. https://github.com/StarpTech/apollo-datasource-http/blob/5f0036f6510790e42c5ecf36900367bb6400514f/src/http-data-source.ts#L328I'm happy to PR clarification once I have it. Just need to know what that is 🙃 .