EDD Cart: how to skip cache?


#1

Hi all,

Using Redis Cache on a multisite, I see there is a rule in common/redis-php7.php that is has something for Woocommerce in particular:

# Don't use the cache for logged in users or recent commenter or customer with items in cart
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart") {
  set $skip_cache 1;
}

Since I’m not using Woocommerce but Easy Digital Downloads on this installation, I can easily adapt this rule to listen for the edd cookie edd_items_in_cart but it says at the top of the file:

# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;

This makes things difficult. Firstly because I don’t want to keep re-modifying files after updates, and secondly because the $skip_cache is set to zero right at the beginning. This means I cannot add my rule to the main site conf file. The $skip_cache will be reset to 0 whatever I do :frowning:

Nor would my rule do any good in the site specific conf dir as these are loaded last.

So how to do this then?

Would it not be nicer to make that cookie signature just a little bit more inclusive with [a-f0-9]+_items_in_cart so that it recognizes at least TWO (and maybe more?) shopping cart plugins instead of just one?


#2

I created a pul request here https://github.com/EasyEngine/easyengine/pull/947

But is easy engine still maintained at all?


#3

By default ee adds this to your main config:- include /var/www/yoursite.com/conf/nginx/*.conf;

Which will load all .conf files it finds in that folder. The idea is that you can add customisations without editing files such as redis-php7.php.

It works well a lot of the time, but not always.

So you can either add your rules to a file in that folder. Or if that doesn’t work for what you want to do, another alternative is to comment out the include for redis-php7.php in your main conf. Then add all of the rules from redis-php7.php to your own file (in yoursite.com/conf/nginx/) customising them as you want.


#4

Hi Marty thanks for the feedback. Sadly, as the rules in /var/www/yoursite.com/conf/nginx/*.conf are loaded after all others, there is no possibility to impact the $skip_cache flag from there. Or am I wrong? I must say, I have not tested this…

Commenting out the include for redis-php7.conf is a nice idea but it will probably mean I will have to remember I cannot do an ee site update anymore as that will restore or update the main site conf file automatically and undo the edit… Still, it’s a nice and useful idea :slight_smile:


#5

Yeah, you’re right, in this case you can’t override the caching as the main cache/php handling is at the end of this file.

So in this case I would personally override by commenting out redis-php7.conf, and creating a custom copy. (Or just adding the rules I want from it into my my main conf). I’ve not checked how ‘ee site update’ handles this so yes, you would need to be careful if you’re making major changes like switching from php5 to php7 via ee. And potentially on major updates of ee itself.

I don’t think there’s a better way round this (anyone?).


#6

Gentlemen, the new EE version (released earlier today, or yesterday depending on your timezone) addresses this issue. :slight_smile:


#7

Excellent :slight_smile: