Caching

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

EndpointCache 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

EndpointCache Duration
Media content (/medias/{product_id})1 week
Media modified since (/media-modified-since)1 day

Pricing and Configuration (PPC) Service

EndpointCache Duration
Available locations1 week
Decoration colors1 week
FOB points1 week
Available charges1 week
Configuration and pricing1 week

Inventory Service

EndpointCache Duration
Filter values1 day
Inventory levels4 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

  1. Leverage caching for catalog imports: When building or updating your product catalog, the cache significantly speeds up the process.

  2. Use incremental sync endpoints: Instead of fetching all data, use endpoints like /products-modified-since and /media-modified-since to only get changed data.

  3. 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.

  4. Bypass cache strategically: Only use Cache-Control: no-cache when you specifically need fresh data, not as a default.