WooCommerce REST API per_page limit inconsistent between local and production
0 reputation · 04 Jul 2020, 15:25 UTC
0 reputation · 04 Jul 2020, 15:25 UTC
WooCommerce REST API product list requests using per_page greater than 100 return more than 100 items on a local development instance, while the same request in production appears capped at 100 items. The documented maximum is 100 per page, but enforcement is not consistent across environments.
Goal: determine whether the difference originates from WooCommerce core pagination logic, server configuration, caching layers, or CDN plugins that normalize response headers such as X-WP-TotalPages.
Assumptions: WooCommerce 7.x or newer, standard /wp-json/wc/v3/products endpoint, no custom REST route overrides. Behavior may differ by release and by active plugins that modify REST responses.
Raw header comparison across environments is required to confirm whether the cap is applied consistently.
35775 reputation · 04 Jul 2020, 22:26 UTC
WooCommerce core enforces a maximum of 100 items per page on the standard /wp-json/wc/v3/products route, regardless of whether the site runs locally or in production. If your local instance returns more than 100 products when you request per_page=150, the excess is coming from outside WooCommerce core—most likely a caching layer, CDN edge cache, or a plugin that modifies the REST response before WooCommerce clamps the argument.
per_page with a maximum of 100 for product list endpoints.A performance plugin, reverse proxy, or CDN active in only one environment is the most probable cause. It may serve a stale local response that was generated before clamping, alter the per_page argument before WooCommerce validates it, or normalize headers such as X-WP-TotalPages so they no longer match the actual payload.
Not without verification. The header reflects the page count calculated from the effective per_page used in the query. If a plugin changes that value before WooCommerce clamps it, the header can describe a different page size than the one you requested. Calculate pages from X-WP-Total and the per_page you actually sent only after confirming the effective limit.
curl -i 'https://example.local/wp-json/wc/v3/products?per_page=150'
curl -i 'https://example.com/wp-json/wc/v3/products?per_page=150'
Record HTTP status, X-WP-Total, X-WP-TotalPages, and the number of JSON objects returned.
rest_api_init, woocommerce_rest_pre_get_product_object, or rest_post_dispatch that could adjust per_page.Are any caching, optimization, or CDN plugins active on the local development instance? The answer changes whether you should first disable local plugins or investigate server-level proxy behavior.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 04 Jul 2020, 17:58 UTC
WooCommerce core applies woocommerce_rest_product_query to limit posts_per_page to the smaller of the requested per_page and 100, so the 100-item cap is enforced in the query layer regardless of server. If a local instance returns more than 100 items, the response is almost certainly a stale cached payload from before the cap was applied or from a custom override, not core behavior.
Compare the raw JSON array length and X-WP-Total and X-WP-TotalPages headers with caching and CDN layers disabled, then re-enable them one by one with a full purge. Header stripping by a CDN can also make pagination appear inconsistent even when the body is correctly capped.