I'm fetching the JWKS from https://X.auth0.com/.well-known/jwks.json server side. I'm wondering if it is safe to cache them for some minutes, because it seems wasteful to constantly barrage that end-point with gets.
I'm using flask and was planning on caching it by doing something simple like:
@cache.cached(timeout=60, key_prefix='auth0/%s')
def get_jwks():
return requests.get("https://" + AUTH0_DOMAIN + "/.well-known/jwks.json").json()
The rest of the implementation is heavily inspired by the auth0 tutorial.
The caching mechanism comes from the library flask_caching, which says:
You are able to use this decorator with any function by changing the
key_prefix