You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your question. I'm not sure you can cache requests based on the result of the authorizer. I haven't encountered anything about how one might do that. Some quick tests also show that API Gateway doesn't accept mapping expressions like method.request.requestContext.authorizer.roles.
However, if your authorization is based on the value of a header, you can cache based on that value. For example, if your app sends a header like Authorization: Bearer <token>, then you can configure caching like this:
That means that each request should be cached based on the value of the Authorization header. If the user's role changes, you also have the option of invalidating the cache when that happens, which would mean sending a request that contains the Cache-Control: max-age=0 header along with any other cache key parameters you have configured, so API Gateway knows which key to invalidate.
Please help. I have the api and I want to cache API base on roles in requestContext return from custom authorizers(picture below). Thanks
![Screen Shot 2021-02-24 at 10 42 34](https://user-images.githubusercontent.com/12195784/108944288-0a49b100-768d-11eb-86a4-83eb2d57a2f5.png)
The text was updated successfully, but these errors were encountered: