The code below validates JWT token by downloading JWKS every time it validates each request following this
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Error: expired token or invalid token" require-expiration-time="true" require-scheme="Bearer" require-signed-tokens="true">
<openid-config url="https://IdentityProvider/oidc/.well-known/openid-configuration" />
<audiences>
<audience>aud id</audience>
</audiences>
</validate-jwt>
My question is how to cache the JWKS from the example link below to avoid downloading it every time, and without hard-coding the JWKS, since it is rotated regularly.
https://demo.identityserver.io/.well-known/openid-configuration/jwks
https://openid-connect-eu.onelogin.com/oidc/certs
Any code example and links for caching and validate JWT would be appreciated.
Below seems relevant but not a complete example.
https://docs.microsoft.com/en-us/azure/api-management/api-management-sample-cache-by-key
Update
Just to be clear, I want to cache the contents from JWKS of the links above to improve performance.