Definitive Engineering Takeaway: Why raising PHP max_execution_time rarely stops 504 Gateway Timeouts under Nginx/LiteSpeed proxies, and how to cure slow WooCommerce queries and import stalls cleanly.
- Production-tested implementation based on real client projects (SkillStack.ie, FloppyFabrics.ie, Aoife Brogan Ballet).
- Zero-bloat execution: strict attention to DOM depth, Core Web Vitals (sub-1.2s mobile LCP), and clean PHP hooks.
- Verified code payloads formatted for rapid copy-paste and direct deployment.
When a WooCommerce store throws 504 Gateway Timeout during checkout, variable product saves, or CSV catalog uploads, beginners often raise PHP max_execution_time = 600 - yet the error keeps firing right at 60 or 100 seconds. Why? Because upstream proxies (Cloudflare, Nginx, LiteSpeed Proxy) drop the gateway wait long before PHP finishes.
1. Why Slow Queries + Blocking Hooks Trigger 504s
| Store Operation | Hidden Bottleneck | Clean Engineering Cure |
|---|---|---|
| CSV / ERP Product Import | Rebuilding term counts & triggering lookup webhooks per row | Disable live indexing mid-import or batch via WP-CLI wp wc |
| Order Checkout AJAX | Uncached shipping API call + synchronous ERP webhook | Cache shipping quotes + async dispatch on woocommerce_payment_complete |
| Admin Order / Variation Save | 50,000+ legacy wp_postmeta rows scanned unindexed | Enable HPOS (wc_orders) + prune orphaned autoloads |
2. Track Down Heavy SQL & Autoload Bloat First
Before scaling server CPU blindly, verify wp_options autoload weight stays below 450 KB and monitor failed or repeating WooCommerce webhooks via our WC Webhook HMAC & Retry Guard plugin.
Diagnostic & Tuning Tools
Quantify your dynamic checkout latency inside our WooCommerce Checkout & HPOS Audit Simulator, audit autoload SQL exports in Autoload Bloat Analyzer, or schedule a WooCommerce Speed Sprint ($299+).
Fix Slow TTFB, Database Bloat & WooCommerce Latency
Run our Free 40-Point Speed Audit, size PHP workers, start with a $49+ quick fix task, or pair Hostinger NVMe Cloud ↗ (99/100 Mobile PSI verified on eosite.com).