The JavaScript file loaded in the custom pixel code is not cached by the browser.

Hello everyone,

I’ve encountered an issue while working with custom pixel code in Shopify customer events. I load my own JavaScript file in custom pixel code, but I noticed that every time the page refreshes, this file is requested again without being cached by the browser. However, JavaScript files loaded through the theme extension approach are cached as expected.

I’d like to know if Shopify intentionally configures customer event files this way, preventing them from being cached. Additionally, is there any way to enable browser caching for this file?

Thank you!

Browser caching is controlled by what server tells the browser.

It’s not quite clear where you are requesting this file from – if it’s your own server then you should configure it to allow caching, if it’s hosted on Shopify servers, then it depends on where exactly it’s stored.

Thank you for your response. This JavaScript file is hosted on my server, and I’ve already set the cache control headers, but it’s still not being cached by the browser. All my other JavaScript files are cached correctly—this one file related to client events just doesn’t work as expected. I’m wondering if this issue could be due to the fact that the client event file is being loaded in Shopify’s sandbox environment.

Yes, it is possible when they load it in an iframe, which they probably do – like additional checkout scripts were finally put into iframe which fixed this loophole used to change checkout page.

Being an event pixel it only makes sense to avoid caching; probably not much you can do about it.

Thanks for your reply, I appreciate you taking the time to help.

1 Like