What's the best way to exclude a certain query string argument from being cached.
I have a location /news/ where I want /news/xyz to be cached but not /news/xyz?view_story=2022.
I have tried the following:
fastcgi_cache_bypass $arg_view_story;
fastcgi_no_cache $arg_view_story;
Unfortunately that doesn't work.
I have also tried calling Cache configuration only for URLs without query strings but it doesn't work either.
location ~ ^/news/([a-zA-Z0-9]+)$ {
## called Cache configuration
}
Appreciate any help in advance!
Finally figured it out.
All you need is two lines:
fastcgi_cache_bypass $is_args;
fastcgi_no_cache $is_args;
Hope this helps anyone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With