-2

I run Woocommerce on Nginx + Mariadb + Php7.3-fpm + Ubuntu 18.04 server.

I googled about excerpt fastcgi cache for woocommerce but so many options i was found.

i was put below code in my server block.

    location ~ \.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_cache_bypass $skip_cache;
     fastcgi_no_cache $skip_cache;
     fastcgi_cache ja.seoartgallery.com;
     include fastcgi_params;
     fastcgi_buffer_size 128k;
     fastcgi_connect_timeout 60s;
     fastcgi_send_timeout 60s;
     fastcgi_read_timeout 60s;
     fastcgi_buffers 256 16k;
     fastcgi_busy_buffers_size 256k;
     add_header X-F-Cache $upstream_cache_status;

    set $skip_cache 0;
   # POST requests and url's with a query string should always skip cache
    if ($request_method = POST) {
        set $skip_cache 1;
    }
    if ($query_string != "") {
        set $skip_cache 1;
    }
    if ( $cookie_woocommerce_items_in_cart = "1" ){
     set $skip_cache 1;
    }
    if ( $arg_add-to-cart != "" ) { 
    set $skip_cache 1;
    }   

    # Don't cache URIs containing the following segments
    if ($request_uri ~* "/wp-admin/|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
         set $skip_cache 1;
    }
    if ($request_uri ~* "/(cart|checkout|my-account)/*$") {
         set $skip_cache 1;
    }

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

Is it right? or need to put other codes?

my product permalink is https://example.com/shop/product-name/ and i am using default url (/cart/, /checkout/ for other pages.

Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.