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.

0

Leave a Reply

Your email address will not be published. Required fields are marked *