E
E
Eugene2018-01-17 15:21:40
Nginx
Eugene, 2018-01-17 15:21:40

How to cache only certain query string requests in nginx?

Goal: configure caching on the nginx side of pages with such addresses

https://examle.com/catalog/category/?product_make=acura

Now the config is written like this:
set $skip_cache 0;
if ($query_string != "") {
        set $skip_cache 1;
    }

and this means that it caches everything except for requests like "/?blablabla=".
How to correctly write a condition in the config so that nginx caches requests with "?product_make=" while not caching all other requests?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Gorgul, 2018-01-25
@xXxSPYxXx

map $args $skip_cache {
default 1;
"~product_make" 0;
}
server {
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question