I have done this. When getting a token, I store it in [KV](https://developers.cloudflare.com/kv/) (u
I have done this. When getting a token, I store it in KV (using KV's feature to automatically expire keys), and also use the Cache API to reduce requests to kv.
So when a request comes in that would require the token, I first check the cache api, then KV (if its in kv then I add it to the cache api before returning), and if its not in either of those then I go and fetch the token, then store it in kv&cache.
Using the cache api is optional, I just use to to reduce requests to KV (therefore, cost)
So when a request comes in that would require the token, I first check the cache api, then KV (if its in kv then I add it to the cache api before returning), and if its not in either of those then I go and fetch the token, then store it in kv&cache.
Using the cache api is optional, I just use to to reduce requests to KV (therefore, cost)