Repository navigation
Actually use the cached search response instead of always refetching - #7
Open
johnnyxmas wants to merge 1 commit into
Open
johnnyxmas wants to merge 1 commit into
johnnyxmas wants to merge 1 commit into
Conversation
GoodreadsSearchProxy.Search passed useCache: false while also passing a
5 day TTL, which are contradictory. CachedHttpResponseService.Get only
reads the cache when useCache is true:
if (useCache && cached != null && cached.Expiry > DateTime.UtcNow)
so every search was written to the cache and then never read from it,
and each repeated search hit the metadata origin again.
That matters because the metadata origin rate limits aggressively: an
uncached query frequently returns 429, which this path surfaces to the
user as an empty result set (there is no retry/back-off here, unlike
BookInfoProxy which calls WaitUntilRetry in several places). Reusing the
cached response for its intended 5 day lifetime removes a large share of
those requests and makes repeated searches resolve instantly.
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GoodreadsSearchProxy.SearchpassesuseCache: falsewhile also passing a 5 day TTL, which are contradictory:CachedHttpResponseService.Getonly reads the cache whenuseCacheis true:It still writes the response to the cache afterwards, so today every search populates a cache entry that is then never read, and each repeated search goes back out to the metadata origin.
Why it matters
The metadata origin rate limits aggressively. In testing, only queries already sitting in the Cloudflare edge cache succeed; anything else hits the origin and is refused:
GoodreadsSearchProxyhas no retry or back-off (unlikeBookInfoProxy, which callsWaitUntilRetryin several places), so a 429 is thrown as aGoodreadsExceptionand surfaces in the UI as an empty result set — which reads to a user as "this author has no books" rather than as an error:Honouring the cache for its intended 5 day lifetime removes a large share of those requests and makes repeated searches resolve instantly from the local DB. It does not fix a first-time search for an uncached term — that still depends on the origin — but it stops the client re-asking for things it already has.
Change
One character:
false→true. The TTL already passed in is unchanged, so cached entries expire after 5 days as originally intended.Test plan
CachedHttpResponseService.GetthatuseCache: falsebypasses the read path while still writing the entryPossible follow-up
GoodreadsSearchProxymight also benefit from theTooManyRequests/WaitUntilRetryhandling thatBookInfoProxyalready has, so a rate-limited search reports an error rather than an empty list. Happy to open that separately if you'd like it.