We recently had an incident that was caused by a deploy of a broken version of our UI extensions. The deploy to production was approved because the tester that validated the release on our staging app was unaware that UI extensions seem to be cached by Shopify’s CDN, with the latest release not always being visible for a few minutes after it’s published. Is there any way to be able to invalidate the cache for UI extensions when a new version is published so that we can guarantee we can (almost) immediately test that code once it’s been published, instead of having to wait for the update to trickle down through the cache? Thanks!
Note: in the meantime we’re considering using the useExtension
hook to retrieve the version
of our app and logging that to the console on extension initialisation, so that testers can at least manually check whether they’re seeing the latest release or not. However, it’d be nice to not have to implement such manual things just for the sake of knowing whether the extension code being served by Shopify is a cached version or the latest release 
3 Likes
Definitely run into similar. The version does already appear in the resource URL, so we tend to just sanity check that number has changed:
1 Like
I ran into the same kind of issue too
1 Like
That’s interesting, thanks. But it feels like this is something that’s internal to Shopify and could change at any time, as well as requiring some poking around to find. I’ll keep it in mind though as a temporary measure!
We don’t offer a method to purge the cache but if this is strictly to test the extension my recommendation would be to look into something like Bugsnag + their releases functionality which can track the new version rollout. You’ll quickly see how many merchants are still on the old vs new. It has the added benefit of tracking bugs by release version. 
You can pass a specific release stage and app version to Bugsnag with something like this:
const APP_SLUG = "production-app-1";
const getExtensionReleaseStage = (version) => {
let releaseStage = "production";
if (version && !version?.startsWith(`${APP_SLUG}-`)) {
const versionParts = version?.split("-");
releaseStage = version.replace(
`-${versionParts[versionParts.length - 1]}`,
""
);
}
return releaseStage;
};
const api = useApi();
Bugsnag.start({
// other config stuff here
appVersion: api?.extension?.version,
enabledReleaseStages: ['production', 'staging'],
releaseStage: getExtensionReleaseStage(api?.extension?.version || null),
});
1 Like