Score:0

Caching 401 response on bad token in nginx njs

in flag

In our application whenever a token (that arrives in a header) is invalid - it is practically guaranteed there won't be an exact valid token. So I'm trying to offload the responsibility of responsding 401 to nginx (with or without njs) Trying to avoid maintaining a service with a cache that is being hammered by invalid requests.

I was thinking to js_content each call and check in a local "in memory cache" of the invalid token or even better to have an API to nginx cache but I can't seem to find documentation on any of the above.

Auth request doesn't seem helpful since I won't have a way populating the cache with a 401 that will be returned from my service (in a "cache miss")

Any other possible way will be welcomed but I would like to acheive the ability to offload this to nginx

djdomi avatar
za flag
`proxy_cache_valid 401 404 60m` maybe is that what you look for
in flag
interesting, but can I cache based on a header and not a URL?
djdomi avatar
za flag
this cache for 404 and 401 header, or what exactly header you mean?
in flag
The API token is in a specific header
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.