System.Return('/syslog')
Web DevelopmentPerformance

WooCommerce Optimization: Caching & Core Web Vitals

Case Study on optimizing a heavy WooCommerce store (Mushtariyat.com) to pass Google's Core Web Vitals and improve mobile conversion rates.

When I launched Mushtariyat.com during the 2020 lockdowns, the goal was feature delivery. By 2023, the goal shifted to performance. The site was handling 5,000+ monthly visits, but the mobile conversion rate was suffering due to high TTFB (Time to First Byte) and poor LCP (Largest Contentful Paint) scores.

Here is exactly how I optimized a heavy WooCommerce installation on a DigitalOcean droplet to pass Google’s Core Web Vitals.

The Baseline (The Problem)

WooCommerce is resource-intensive. Every page load involves multiple database queries (products, categories, cart fragments).

  • Initial TTFB: ~1.2 seconds
  • LCP (Mobile): ~4.5 seconds
  • Database: Straining under concurrent connections during sales campaigns.

1. Replacing Apache with NGINX

The droplet was running an older LAMP stack. Apache’s process-based model consumes significant RAM under load.

The Fix: Migrated the server to a LEMP stack (Linux, NGINX, MySQL, PHP-FPM). NGINX’s event-driven architecture handled concurrent connections far more efficiently, dropping idle RAM usage by 30%.

2. Server-Side Caching (Redis)

The biggest bottleneck in WordPress is the database. Without object caching, WP queries the database for every single option and transient on every page load.

The Fix:

  1. Installed Redis server on the Linux droplet.
  2. Configured the Predis PHP extension.
  3. Connected WooCommerce to use the Redis Object Cache.

Result: Database queries per page dropped from ~90 down to ~15. TTFB dropped from 1.2s to 300ms.

3. Disabling WooCommerce Cart Fragments (AJAX)

By default, WooCommerce fires an AJAX request (/?wc-ajax=get_refreshed_fragments) on every single page load to check if the cart needs updating. This bypassed all page caching and slowed down the site immensely.

The Fix: Dequeued the script entirely on all pages except the actual store/product pages using functions.php:

add_action( 'wp_enqueue_scripts', 'dequeue_wc_cart_fragments', 11 );
function dequeue_wc_cart_fragments() {
    if ( is_front_page() || is_single() ) {
        wp_dequeue_script( 'wc-cart-fragments' );
    }
}

4. Image Optimization via CDN

High-res cosmetic images were dragging down the LCP.

The Fix:

  1. Offloaded all /wp-content/uploads to a Cloudflare CDN.
  2. Implemented WebP auto-conversion at the edge layer.
  3. Added strict fetchpriority="high" attributes to the Hero image to force early loading.

The Results

After implementing these changes:

  • TTFB: 300ms (75% improvement)
  • LCP (Mobile): 1.8 seconds (Passed Core Web Vitals)
  • CPU Load: Dropped by 40% during sales events.

Business Impact: The mobile conversion rate increased by 1.2% within 30 days of the updates, proving that millisecond improvements directly correlate to revenue.