feat(Algolia.Api): cache requests #1771
Merged
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 of changes
Asana Ticket: No ticket
While working on the autocomplete widget I noticed an opportunity for us to cache our requests to the Algolia REST API!
This PR uses our existing
RepoCache
module to cache the POST requests we make to Algolia, based on two parametersbody
. It's a gnarly string of text looking something like this (yes it's a query for the letterr
).It'll have different params depending on the type of search (e.g. the request body for searching
r
in the trip planner will look different as it'll just search for 3 stops instead of 2 stops, 5 routes, and results from the CMS). So the results for one search box is not necessarily cached for use by a different search box in the website -- that'll only happen if both perform exactly the same query with exactly the same sets of parameters.2. The Algolia configuration - this is just a struct that captures the API keys in use. I figure caching should only be valid if the request is made with the same API keys.
General checks