Latest Notes on Woocommerce and wpfc?

The comments on the rtcamp tutorial for woocomerce are closed, are the tweaks suggested in that tutorial still relevant/required with v3 of ee?

I ask because without creating a new .conf file and pointing nginx config for the vhost to the custom commmon file, everything seems fine.

Hi @datagroove

Yes. Configurations are still relevant to EE v3. You should use side edit option to add the WooCommerce specific rules.

ee site edit example.com

Thanks @radhakrishnanmu for confirming woocommerce tweaks are still required/suggested.

Last updated suggestion:

Can rtCamp please consider adding “last updated” meta to the tutorials? Or something that suggests they are still relevant and suggested. Or shall we assume if they are online they are still relevant?

CONF File

Also, can you please confirm that this code is still valid and currently suggested replacement for the wpfc.conf file for us woocommerce users,

# WPFCWC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
    set $skip_cache 1;
}
if ($query_string != "") {
    set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
    set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
    set $skip_cache 1;
}
# Skip cache on WooCommerce pages
if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
    set $skip_cache 1;
}
# Skip cache for WooCommerce query string
if ( $arg_add-to-cart != "" ) {
    set $skip_cache 1;
}
# Skip cache when WooCommerce cart is not empty
if ( $cookie_woocommerce_items_in_cart != "0" ) {
    set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
    try_files $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
    try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
    # try_files $uri =404;

    set $rt_session "";

    if ($http_cookie ~* "wc_session_cookie_[^=]*=([^%]+)%7C") {
        set $rt_session wc_session_cookie_$1;
    } 

    if ($skip_cache = 0 ) {
        more_clear_headers "Set-Cookie*";
        set $rt_session "";
    }

    fastcgi_cache_key "$scheme$request_method$host$request_uri$rt_session";

    try_files $uri =404;

    include fastcgi_params;
    fastcgi_pass php;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    fastcgi_cache WORDPRESS;
}
location ~ /purge(/.*) {
    fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}

maybe even link to a gist or file from the tutorial page:

I am not sure if WooCommerce gist will work now.

Since we moved our own store to EasyDigitalDownloads, I stopped experimenting with WooCommerce. It really hard to experiment on things that you don’t use daily.

Overall, trick is to cache store pages until a visitor add something to cart. So basically, we need to track cart related cookie and bypass cache if cart has something added. This way, people with items in cart won’t get cached response and cart collision can be avoided.

If you are facing problem with config in gist, please let me know. I will try to debug it.