cdnjs / api-server

📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
https://api.cdnjs.com
MIT License
89 stars 38 forks source link

Add caching for Algolia calls #77

Closed MattIPv4 closed 2 years ago

MattIPv4 commented 2 years ago

Type of Change

What issue does this relate to?

N/A

What should this PR do?

Adds KV-based caching to Aloglia index calls, with the aim to reduce the number of calls we're actually making to Algolia by caching results for each unique query in KV for 15 minutes at a time.

TODO:

What are the acceptance criteria?

Repeat calls to the libraries endpoint with identical queries will rely on cached results for 15 minutes, instead of making API calls to Aloglia every time.

Identical requests with query params in a different order, or a fields list containing the same values but in a different order, will be normalized and share the same cached results.