Can someone help me figure out how to implement cache for a token request (**POST**) made to an exte

Can someone help me figure out how to implement cache for a token request (POST) made to an external API within the worker function?

e.g. I'm making a POST request to an external API https://example.com/token within my worker, I can specify the expiration in seconds in the body of this POST request. It then returns access token and
expires_in
field in seconds. I'm looking to cache this token and use the
expires_in
field to calculate whether to return the same token or make a new request to create a new token and then cache that new token instead.
Was this page helpful?