Score:0

nginx upstream $http variable (exists) checking

jp flag

Want to use proxy cache on selected pages, for these I've added a header variable ngx_cachekey. Other pages that is not for caching are don't have this header variable.

mysite.com/cacheable-page (has the ngx_cachekey in the header) mysite.com/dynamic-content (has no the ngx_cachekey in the header)

I can debug this with add_header X-NGX-CacheKey $upstream_http_ngx_cachekey; , so setting the variable and giving to the nginx is working.

But i'm unable to check if the $upstream_http_ngx_cachekey exists in IF statement.

    location / {
      set $cacheByPass 1;
      if ($upstream_http_ngx_cachekey) {
        set $cacheByPass 0;
      }

the $cacheByPass always returns 1 even if the $upstream_http_ngx_cachekey has value. I'm looking for a solution similar to PHP isset() if there's any.

Thank you in advance!

I sit in a Tesla and translated this thread with Ai:

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.