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 with preload hints. These cover 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
- The SDK rewrites image URLs to use your storefront domain (derived from the request
Refererheader) instead of the Shopify CDN domain. This improves cache hit rates when your storefront proxies images - Generates responsive srcset entries at standard breakpoints (360, 540, 720, 900, 1080 pixels)
Customization
You can configure early hints behavior 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 |
Per-request overrides
You can override the default preload behavior on individual search and browse requests with theresponseOptions.mediaPreloads body parameter. This is useful when:
- A specific page (such as a server-rendered template or a back-office tool) does not benefit from preload hints and you want to skip the extra
Linkheader. - Your client only renders specific image breakpoints and you want the emitted
imagesrcsetto match exactly, avoiding wasted preloads.
enabled: falseskips theLinkheader for this request only.enabled: truecannot turn preloads on when they are disabled at the store level — store settings always take precedence.srcsetSizesaccepts integers between1and10000. When provided, it overrides the store-level srcset configuration for this request only. Omit it to fall back to the store configuration or platform defaults.- When preloads are emitted, the response body’s
_meta.mediaPreloads.srcsetSizesechoes the breakpoints that were used so you can verify the override took effect.
Next steps
Caching
Deep dive into SDK caching behavior.
Best Practices
Review SDK best practices and common pitfalls.