I have a problem with the rewrite rules in my nginx config file.

I am running wordpress with nginx and redis to cache the site.

I can get the redis to cache all pages not a problem, but as I am using jigoshop which when you add a product to the basket submits a form and then adds some javascript into the page to say 'Product has been added to basket' kind of thing.

My problem is I want redis to cache all the pages event the product except for when a user adds a product to the basket we want to remove the product from the cache, so that it returns the 'Product has been added to basket' in the page.

In the nginx config file I can add the following:

location /product {
    index index.php;
    try_files $uri $uri/ /index.php?$args;
}

This will stop all of the products from using redis it hits the index.php file, but what i want is something like:

location (\?[add\-to\-cart]+) {
    index wp-index-redis.php;
    try_files $uri $uri/ /wp-index-redis.php?$args;
}

The problem is the location does't seem to see the regex.

Any ideas or help would be gratefully appreciated.

  • I know this is pretty old. Just wondering if you found a solution? – geoffmcc Jan 14 '15 at 18:50
  • I ask because I am just now experimenting with wordpress and redis – geoffmcc Jan 14 '15 at 19:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.