litespeedtech / litespeedtech/lscache_wp

LiteSpeed Cache fails to cache any pages when WooCommerce ≥ 10.1 is active

Open
#962 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
257
Forks
123
PR merge metrics
No merged PRs in 30d

Description

**Environment:**
- LiteSpeed Cache: 7.8.0.1
- WooCommerce: 10.6.1
- OpenLiteSpeed (not LiteSpeed Enterprise)
- PHP 8.3

**Description:**
Since WooCommerce 10.1.0, _WC_Cache_Helper::prevent_caching()_ was moved from the _wp action_ to the _wp_headers_ filter at priority 5 (see [comments in code](https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-cache-helper.html)). This change causes LiteSpeed Cache to never cache any pages on WooCommerce stores.

**Root cause:**
WooCommerce's _prevent_caching()_ now fires on _wp_headers_ unconditionally for every page load, calling _set_nocache_constants()_ which defines _DONOTCACHEPAGE = true_. LiteSpeed Cache's WooCommerce compatibility handler (_thirdparty/woocommerce.cls.php_) was written to handle the old _wp action hook_ and does not override the new _wp_headers_ hook. As a result, _DONOTCACHEPAGE_ is always true before LiteSpeed finalises cache control, causing _Control::is_cacheable()_ to return false for every request.

**Symptoms:**
- All pages return _X-LiteSpeed-Cache-Control: no-cache_
- LiteSpeed debug log shows _not cacheable before ctrl finalize_ on every request
- No pages are ever stored in the OLS cache
- High PHP memory usage as every request hits origin (no cache hits)

**Verification:**
With WooCommerce 10.6.1 active, _DONOTCACHEPAGE_ is always defined as true by the time _LiteSpeed's Control::finalize()_ runs at shutdown. Removing WooCommerce's hook manually confirms this is the cause — with the hook removed, _DONOTCACHEPAGE_ remains undefined and pages cache correctly with _public,max-age=604800_.

**Workaround:**
Add the following to a must-use plugin:

```
php

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in thirdparty/woocommerce.cls.php and trace the compatibility handling around WooCommerce's wp_headers hook, then check how Control::is_cacheable() and Control::finalize() respond to DONOTCACHEPAGE. Test with WooCommerce 10.6.1 that cacheable pages no longer return no-cache while cart, checkout, and account exclusions remain effective.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.