Caching
Overview
PSRESTful implements on-demand caching to enhance API performance, particularly for catalog creation operations. Our caching approach follows the recommendations of the PromoStandards Best Practices Committee and aims to reduce server load while accelerating response times.
Caching is especially valuable when importing large product catalogs from major suppliers, substantially decreasing the time needed for full catalog imports.
How It Works
When you make an API request, PSRESTful checks if a cached response exists for that specific request. If a valid cached response is found, it’s returned immediately without contacting the supplier’s server. If no cache exists or it has expired, PSRESTful fetches fresh data from the supplier, caches it, and returns the response.
Cache Timeouts by Service
Different services have different cache durations based on how frequently the underlying data typically changes:
Product Data Service
| Endpoint | Cache Duration |
|---|---|
Sellable products (/sellable-products) | 1 day |
Individual products (/products/{id}) | 1 week |
Closeout products (/products-closeout) | 1 day |
Products modified since (/products-modified-since) | 1 day |
Media Content Service
| Endpoint | Cache Duration |
|---|---|
Media content (/medias/{product_id}) | 1 week |
Media modified since (/media-modified-since) | 1 day |
Pricing and Configuration (PPC) Service
| Endpoint | Cache Duration |
|---|---|
| Available locations | 1 week |
| Decoration colors | 1 week |
| FOB points | 1 week |
| Available charges | 1 week |
| Configuration and pricing | 1 week |
Inventory Service
| Endpoint | Cache Duration |
|---|---|
| Filter values | 1 day |
| Inventory levels | 4 hours |
Transactional Services (No Caching)
The following services operate transactionally and are not cached:
- Purchase Order Service - Orders are always sent in real-time
- Order Status Service - Status is always fetched fresh
- Invoice Service - Invoices are always fetched fresh
- Order Shipment Notification (OSN) - Notifications are always fetched fresh
Bypassing the Cache
If you need to retrieve fresh data and bypass the cache, add the Cache-Control header to your request:
curl -X GET "https://api.psrestful.com/v2.0.0/suppliers/HIT/products/5989/" \
-H "X-API-Key: your-api-key" \
-H "Cache-Control: no-cache"When to Bypass Cache
- When you know a supplier has just updated their data
- When debugging data discrepancies
- When you need real-time inventory for order placement
Note: Bypassing cache increases response time and puts additional load on supplier servers. Use sparingly and only when necessary.
Best Practices
-
Leverage caching for catalog imports: When building or updating your product catalog, the cache significantly speeds up the process.
-
Use incremental sync endpoints: Instead of fetching all data, use endpoints like
/products-modified-sinceand/media-modified-sinceto only get changed data. -
Plan around cache durations: Schedule your sync jobs knowing that inventory data is cached for 4 hours while product data is cached for up to a week.
-
Bypass cache strategically: Only use
Cache-Control: no-cachewhen you specifically need fresh data, not as a default.
Related Documentation
- Rate Limits - API usage limits
- Design Decisions - Why we built PSRESTful the way we did