Caching based on a header (like an Auth token) #192
Unanswered
rishab-goel-dev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using a GET endpoint which essentially takes in an azure auth token in the header alongwith 1 query parameter.
Currently I'm using the InMemoryBackend() for caching.
The response of the API essentially changes if the header token changes. The header token has an expiration of 60 mins so after that a new token needs to be passed.
However, when testing in the Swagger, it seems like the @cache decorator doesn't take into consideration the header of the api endpoint.
Here is the initialisation:-
cache = FastAPICache() cache.init(cache_backend:=InMemoryBackend(), expire=20)
I have even tried building two different key_builders based of the default_key_builder() which I directly provide in the key_builder argument of the @cache decorator. But still the query remains cached even if I provide a wrong auth token or a different one.
Here they are:-
So does anybody have some suggestion as to what would be the best method for basing the caching based on headers and query params values.
Beta Was this translation helpful? Give feedback.
All reactions