Reputation: 4830
I have a basic rewrite happening in my main block:
location / {
try_files $uri $uri/ /index.php.php?$is_args$args
}
Now i would like to remove caching from all requests that starts with /api/. I was tempted to use "if" in my location block but according to nginx doc that is not a good practice.
I also try to nest a block hoping there would be some inheritence happening but i don't think i got that right as /api requests to not get handed to PHP.
location / {
location /api/ {
expires -1;
}
try_files $uri $uri/ /index.php.php?$is_args$args
}
So what would be the best way to go about this?
Upvotes: 0
Views: 529
Reputation: 14372
Try this:
location / {
try_files $uri $uri/ /index.php;
}
location /api/ {
expires epoch;
try_files $uri $uri/ /index.php;
}
I've removed $args
. You could get them in PHP from fastcgi params, so there is no need to have them here.
Upvotes: 2