Purpose: If you're experiencing a delay importing your WooCommerce orders into Sendcloud, it could be related to cache. In this article, we explain how to troubleshoot and fix this issue.
Note: The fixes in this article require some development knowledge. In case you're not qualified, we advise you to contact your web developer. The fix for this issue must take place in your own environment (not in Sendcloud), therefore we can only make a recommendation on how to resolve this issue.
Why is there a delay importing my orders into Sendcloud?
Delays in importing orders can be caused by multiple reason, but in this article we discuss order delays related to cache. By design, it's impossible to retrieve all of your orders at once. Because of this, Sendcloud uses pagination and cache.
What is pagination?
Pagination is a feature which splits all orders into smaller sets and retrieves the results page by page. Sendcloud then just needs to specify the required page number in our API request.
What is cache?
Cache helps shop systems to be more productive and efficient. Instead of making heavy database queries and calculations per API request, you receive responses (e.g. orders) which were already prepared and stored from previous API requests. Due to the cache functionality, the latest orders cannot always be retrieved. This is because the newest orders are in the database, but have not yet been cached. Once the cache is cleared (every N minutes/hours), the newest orders will be retrieved by our API call and imported into the Sendcloud panel.
It might seem like your orders are being imported in the Sendcloud panel with delay. This delay is related to cached data. Unfortunately, the cache is something Sendcloud can't control. The best we can do is indicate to WooCommerce that we don't want cached data at all. If API servers respond with outdated data, you'ill see outdated data in the Sendcloud panel too.
Possible root causes:
Cache on hosting provider side, which caches everything for similar requests
Installed cache plugins
Ineffective cache strategy installed by webshop developers
In order to know whether your delays are due to a caching issue, perform the steps below:
- Find the requests Sendcloud sends in your server logs; it should look something like this:
- Copy the URL
- If requests logs can't be found, use the API (this is for experienced users or developers)
- Make a request from the browser or a REST client (e.g. Postman, Insomnia etc.)
- Check the response data
- Wait until new orders appear or create a test order
- Make the same request from the same browser or the same Postman session
- Check the response data again
- If the new batch of data is the same as the previous one, and doesn’t include the latest (or test) order, this means that there is a cache problem
Solution 1: Invalidate cache for new orders
When new orders are placed, Woocommerce should automatically invalidate/clear the cache.
The next time Sendcloud tries to retrieve orders, it'll retrieve them directly from the database instead of the cache.
Solution 2: Cache-control HTTP header
Sendcloud will send HTTP header Cache-Control in each request we do to retrieve new orders. When the Woocommerce API server sees this header in our request, it should not use cache or at least invalidate it, and therefore, we will be able to retrieve all the latest orders.
You can find more information about how to do this by reading this documentation.
If the fixes in this article don't solve the delay, please contact Customer Support.