Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest Data Source - always checks cache no matter cache settings can we make it configurable? #7881

Open
cliftonc opened this issue May 22, 2024 · 0 comments

Comments

@cliftonc
Copy link

We are actively using Apollo, and the Rest Data Source with Redis as our overall cache for some legacy APIs. We have quite a few GET Api's that we never want cached, that return correct no-cache headers, and to be explicit we have also set the cacheOptions ttl to zero.

However, we can still see a lot of un-necessary MGET url in our logs, due to the code:

https://github.com/apollographql/datasource-rest/blob/main/src/HTTPCache.ts#L78

This code means that it will always check the cache for every request that is not a HEAD.

Would you consider a PR that if the ttl has been manually set to zero, it should not check the cache for values, or perhaps an additional explicit value so as not to break existing behaviour? Something along the lines of:

const neverCache = !requestOpts.cache?.cacheOptions?.ttl || !requestOpts.cache?.cacheOptions?.neverCache;
if (neverCache) {
    return { response: await this.httpFetch(urlString, requestOpts) };
}

This would avoud (for us at least) hundreds of thousands of pointless MGET requests to our cache!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant