Concurrent requests
Execute independent requests in parallel:Prefetch next page
Prefetch the next page while the customer views the current page:Request only needed attributes
Reduce response size by requesting only required attributes:Debouncing
The SDK handles debouncing automatically, but you can tune it:Warm cache on page load
Preload common queries on page load:Early hints (Link header preloading)
Layers API responses automatically include HTTPLink headers with rel="preload" directives for product images in search and browse results. These headers enable browsers and CDNs to begin fetching images before your application processes the JSON response, reducing perceived load time.
How it works
When a search or browse request returns results, the response includes aLink header containing preload hints for the featured_media images of the first results (up to 6 items). Each hint includes a responsive imagesrcset with multiple sizes so the browser can select the optimal resolution.
Example response header:
Default behavior
- Enabled by default for all stores
- Covers the first 6 product images in the response
- Image URLs are rewritten to use your storefront domain (derived from the request
Refererheader) instead of the Shopify CDN domain, which improves cache hit rates when your storefront proxies images - Generates responsive srcset entries at standard breakpoints (360, 540, 720, 900, 1080 pixels)
Customization
Early hints behavior can be configured per store through the Layers dashboard. Available options include:| Option | Description | Default |
|---|---|---|
| Enabled | Toggle early hints on or off | true |
| Srcset sizes | Custom responsive image widths (in pixels) | Platform defaults |
| Rewrite domain | A specific domain to use for image URLs instead of the referrer domain | Referrer domain |
| Rewrite URLs | Whether to rewrite Shopify CDN URLs to your storefront domain | true |
Next steps
Caching
Deep dive into SDK caching behavior.
Best Practices
Review SDK best practices and common pitfalls.