Reducing OCAPI round trips and response payload size
Key Takeaway
To make fewer OCAPI calls, use a batch request or expand. To get smaller responses, use select. To skip calls for unchanged data, reuse it until the Cache-Control max-age value runs out.
Every OCAPI call costs a network round trip and server work. Oversized responses also waste bandwidth. B2C Commerce gives developers request-level tools to cut both. Batch requests bundle many calls into one. The select parameter trims a response to only the properties you need. The expand parameter pulls related product data into a single response. Many Shop API responses also carry Cache-Control headers that tell a client how long it can reuse data before it calls again.
Match the tool to the problem
Start by naming the problem, because each tool fixes a different one.
| Problem | Tool |
|---|---|
| Too many calls | A batch request or the expand parameter |
| Too much data in each response | The select parameter |
| Repeated calls for unchanged data | Honor the Cache-Control max-age value |