WooCommerce API Caching




Wordpress LScache Plugin: WooCommerce API Caching

Last Updated on: Wed, 15 Apr 2026 00:00:02
We have Cache REST API on the Cache setting page enabled, but see that WooCommerce related API calls are not cached.? Two queries: 1. Presumably the x-litespeed-cache HTTP header would be set to HIT on the API request if caching was working? 2. Do we need to add WooCommerces API endpoints as they are not default? Report number: TREFOYYZ Report date: 03/07/2022 14:53:56 Thanks. Ian. This topic was modified 8 months, 3 weeks ago by ianatkins. Hi, please screenshot me the full request header and response header on that API Best regards, Hi Qtkrk, Request Headers: https://pasteboard.co/hpxcoK213MaL.png Response headers: https://pasteboard.co/ewsBzJmIwJCR.png Domain and consumer secret / key redacted. Endpoint is /wp-json/wc/v2/orders Would it be expected that Litespeed does normally cache WooCommerce API endpoints? Thanks. Ian. what is the request header ? Sorry missed that originally, my reply has been edited to include it. didnt see any immediate reason , thought it of being POST request, but seems not you can follow this guide to enable debug log , it will log the reason for why no-cache best regards, Output below, was run in a private browsing window: Seems its not caching as the basket is empty?! X Cache_control -> no Cache ( 3rd party woocommerce not cache due to null cart ) ` Also seems abit odd that the CDN replacements are run on an API request for JS, Fonts and CSS? ( guess media makes sense ). Thanks. 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] ------GET HTTP/1.1 (HTTPS) /wp-json/wc/v2/orders 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] Query String: page=1&per_page=100&status=pending&consumer_key=xxxxxx&consumer_secret=xxxxx 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] User Agent: Mozilla/5.0 (Macintosh Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Safari/605.1.15 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] Accept: text/html,application/xhtml+xml,application/xml q=0.9, / q=0.8 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] Accept Encoding: gzip, deflate, br 03/08/22 15:46:15.553 [45.235.218.229:62970 1 gYI] X-LSCACHE: true 03/08/22 15:46:15.769 [45.235.218.229:62970 1 gYI] [Ctrl] X Cache_control -> private ( logged in user ) 03/08/22 15:46:15.769 [45.235.218.229:62970 1 gYI] [Router] get_role: administrator 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [Media] init 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [Avatar] init 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [LQIP] init 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [CDN] init 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [CDN] mapping inc_img -> https://cdn.domain.com/ 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [CDN] mapping inc_css -> https://cdn.domain.com/ 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [CDN] mapping inc_js -> https://cdn.domain.com/ 03/08/22 15:46:15.770 [45.235.218.229:62970 1 gYI] [CDN] mapping .aac,.css,.eot,.gif,.jpeg,.js,.jpg,.less,.mp3,.mp4,.ogg,.otf,.pdf,.png,.svg,.ttf,.woff -> https://cdn.domain.com/ 03/08/22 15:46:15.771 [45.235.218.229:62970 1 gYI] Task init 03/08/22 15:46:15.771 [45.235.218.229:62970 1 gYI] [Router] LSCWP_CTRL bypassed empty 03/08/22 15:46:15.771 [45.235.218.229:62970 1 gYI] [GUI] init 03/08/22 15:46:15.837 [45.235.218.229:62970 1 gYI] [Ctrl] X Cache_control init on 03/08/22 15:46:15.911 [45.235.218.229:62970 1 gYI] [REST] Internal REST ON [filter] rest_request_before_callbacks 03/08/22 15:46:15.914 [45.235.218.229:62970 1 gYI] [REST] Internal REST OFF [filter] rest_request_after_callbacks 03/08/22 15:46:15.926 [45.235.218.229:62970 1 gYI] [Vary] Rest API init disabled vary change 03/08/22 15:46:16.023 [45.235.218.229:62970 1 gYI] [REST] Internal REST ON [filter] rest_request_before_callbacks 03/08/22 15:46:17.738 [45.235.218.229:62970 1 gYI] [REST] Internal REST OFF [filter] rest_request_after_callbacks 03/08/22 15:46:17.742 [45.235.218.229:62970 1 gYI] [Tag] Add --- HTTP.200 03/08/22 15:46:17.745 [45.235.218.229:62970 1 gYI] [Core] CHK html bypass: miss footer const 03/08/22 15:46:17.746 [45.235.218.229:62970 1 gYI] [Ctrl] X Cache_control -> no Cache ( 3rd party woocommerce not cache due to null cart ) => LiteSpeed Control::set_nocache(( 3rd party woocommerce not cache due to null cart ))@362 => WP_Hook->apply_filters(,ARRAY)@307 => WP_Hook->do_action(ARRAY)@331 => /home/gallinee/public_html/wp-content/plugins/litespeed-cache/thirdparty/woocommerce.cls.php@474 => LiteSpeed hirdparty WooCommerce->set_control()@613 => WP_Hook->apply_filters(,ARRAY)@307 03/08/22 15:46:17.746 [45.235.218.229:62970 1 gYI] [Ctrl] not cacheable after api_control 03/08/22 15:46:17.746 [45.235.218.229:62970 1 gYI] [Vary] role in vary_group [group] 99 03/08/22 15:46:17.746 [45.235.218.229:62970 1 gYI] [Vary] show_admin_bar_front: true 03/08/22 15:46:17.746 [45.235.218.229:62970 1 gYI] [Vary] admin bar : true 03/08/22 15:46:17.747 [45.235.218.229:62970 1 gYI] [Vary] can_change_vary bypassed due to litespeed_can_change_vary hook 03/08/22 15:46:17.747 [45.235.218.229:62970 1 gYI] [Vary] no custimzed vary 03/08/22 15:46:17.747 [45.235.218.229:62970 1 gYI] [Core] Silence Comment due to REST/AJAX 03/08/22 15:46:17.747 [45.235.218.229:62970 1 gYI] X-LiteSpeed-Cache-Control: no-cache 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [Core] CHK html bypass: miss footer const 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [Media] bypass: Not frontend HTML type 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] GUI bypassed by no counter 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] CDN _finalize 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [CDN] _replace_inline_css --- array ( inc_img => https://cdn.domain.com/, inc_css => https://cdn.domain.com/, inc_js => https://cdn.domain.com/, filetype => true, .aac => https://cdn.domain.com/, .css => https://cdn.domain.com/, .eot => https://cdn.domain.com/, .gif => https://cdn.domain.com/, .jpeg => https://cdn.domain.com/, .js => https://cdn.domain.com/, .jpg => https://cdn.domain.com/, .less => https://cdn.domain.com/, .mp3 => https://cdn.domain.com/, .mp4 => https://cdn.domain.com/, .ogg => https://cdn.domain.com/, .otf => https://cdn.domain.com/, .pdf => https://cdn.domain.com/, .png => https://cdn.domain.com/, .svg => https://cdn.domain.com/, .ttf => https://cdn.domain.com/, .woff => https://cdn.domain.com/, ) 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [CDN] replace attribute .src 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [CDN] replace attribute .data-src 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [CDN] replace attribute .data-srcset 03/08/22 15:46:17.749 [45.235.218.229:62970 1 gYI] [CDN] replace attribute .href 03/08/22 15:46:17.750 [45.235.218.229:62970 1 gYI] [CDN] replace attribute .poster 03/08/22 15:46:17.750 [45.235.218.229:62970 1 gYI] [CDN] replace attribute source.srcset 03/08/22 15:46:17.750 [45.235.218.229:62970 1 gYI] End responseExpand well , its not exactly running , but more like initializing it seems that 3rd party is overriding the cache , have you tried with force cache option on this URI ? Hi Qtwrk Thanks for the update, before I test that ? do you mind confirming how that would work. Would the API request still get refreshed when new orders come in, with the force cache option enabled? Would I also have to add one line per query string for them to be unique? Will check our plug-ins in the interim to see if I can spot where that no cache is coming from. Thanks, Ian. hold on a second , what exactly is your goal here ? to cache WC REST or something ? Yes to cache the api responses, but not to serve stale content. Let me know if litespeed wont do this. no , by default it wont work that way for case like this but yes , it is still doable although need some custom code to add some function to make it work



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference