FEEDBACK FOR DEVS: Script Tag force cache refresh

Appifiny
Shopify Partner
146 2 37

Hi

It would be useful to have an API method for script tags that sets a parameter to force a client browser to reload the file instead of loading from cache.

Useful for when you have a made a change to a script stored on a remote server and you want to make sure that all client browsers are using that latest script.

EDIT:

I've just noticed it's possible to add a parameter to a script tag which can be modified.

Try the best recent order app for Shopify free for 7 days: https://apps.shopify.com/recently
hassantahir01
Shopify Partner
5 0 1

Any update on it?

0 Likes
OliUK
Shopify Partner
192 2 31

I've been running into the cache problem with the Script Tag API. My workaround is to un-install, then re-install my app in my development store's admin panel. Shopify removes all script tags when an app is uninstalled.

This isn't too much of an inconvenience for me, as my development store's entries in my app's database are untouched throughout this process.

 

Hope this helps someone.


Cheers,

 

Oli

Appifiny
Shopify Partner
146 2 37

@OliUK, you don't need to go that far. You can modify the script tag with a PUT request and append a timestamp to the URL.

You just need to store the ID of the script tag that you want to modify somewhere when you create it.

PUT /admin/api/2020-07/script_tags/596726825.json
{
  "script_tag": {
    "id": 596726825,
    "src": "https://somewhere-else.com/another.js?v=1234567890"
  }
}

When you need to make a change to the script file, you can update the source of the script tag with a new timestamp.

Hope this helps

 

Try the best recent order app for Shopify free for 7 days: https://apps.shopify.com/recently
OliUK
Shopify Partner
192 2 31

@Appifiny that's great mate, thanks.

0 Likes
dom-linq
Shopify Partner
30 1 9

@Appifiny This was very helpful thanks! I was having issues with customers sometimes not seeing updates because of caching but this fixed it.

0 Likes