FEEDBACK FOR DEVS: Script Tag force cache refresh

Highlighted
Shopify Partner
143 2 27

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
1 Like
Highlighted
Shopify Partner
5 0 0

Any update on it?

0 Likes
Highlighted
Explorer
100 2 15

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

1 Like
Highlighted
Shopify Partner
143 2 27

@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
1 Like
Highlighted
Explorer
100 2 15

@Appifiny that's great mate, thanks.

0 Likes