[Bug]: Fetch Request Handling POS Extension

Hello,

Currently POS Extensions don’t respect Cache Control headers and also don’t respect CORS Max Age.

This results in a lot more requests made to APIs, but also a slower user experience on the tiles as more requests and time is spent on these requests

I suspect this is due to fetch/window being overridden by Shopify to enable/disable other features and apis.

1 Like

@JordanFinners is this on unstable? What kind of request are you making? Just a regular request to your server?

Hey JS,

Just making standard fetch request, on version 2025-04.

I think somewhere in the wrapped fetch its setting "cache-control": "no-cache"

I can see this on the API requests, but I’m not setting it and cache is set to default on the fetch requests.

fetch("url", {
  "headers": {
    "accept": "application/json",
    "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
    "authorization": "Bearer X,
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "sec-ch-ua": "\"Chromium\";v=\"136\", \"Android WebView\";v=\"136\", \"Not.A/Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?1",
    "sec-ch-ua-platform": "\"Android\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "cross-site",
    "x-device-id": "e9",
    "x-requested-with": "com.shopify.pos"
  },
  "referrer": "https://extensions.shopifycdn.com/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "include"
});

My response, changed to make it public and max age longer just to try force it

I tried manually overriding the request header, which does work. However even when thats set to allow a cache its still not respected.
You can also see here that the CORS preflight cache isn’t respected as it makes the options request every time, adding time to a customers use of my app for each interaction.

@Henry_Tao I don’t see anywhere in our wrapped fetch where this is being overridden. Am I missing something?

Hey @JS_Goupil,
Sorry I updated my comment, even when I override the cache control headers manually on the request it still doesn’t cache.
So I’m wondering if its something more fundamental with the UI Extension/web worker stuff.