How can I reset a referenced resource in Lovelace

Hi
When implementing custom cards, you reference a resource in ui-lovelace.yaml like so:

resources:
  - url: /local/my-test.js
    type: js

But when you edit the code in the .js, to avoid using outdated code you need to implement version numbers and increment up as you implement new changes.

resources:
  - url: /local/my-test.js?ver=2
    type: js

Is there a way to reset back to the start so I can omit the version referencing, now that I am happy with my working code?

Thanks

The ‘?ver=2’ parameter is just a way to “fool” the cache in your web browser.

The problem is your web browser caches most files locally, which results in edits on the server not being taken over in the browser. By appending ‘?ver=3’ your web browser sees a different filename and reloads it from the server, the server splits the filename at the question mark, only interpreting the left part as filename (so it is still the same file on the server), and passing the right part along as parameters. These are unused, so instead of ‘?ver=4’ you could as well use ‘?homeassistant=awesome’. Only be sure to change it to something else if you make changes and you want the browser to reload it.

Another solution is to clear the cache of your browser, than no ‘?ver=5’ parameter is needed, but this can be quite bothersome if you have multiple users and multiple browsers.

tl;dr the ‘?ver=6’ argument is nothing but a trigger to the browser to reload the file from the server instead of relying on the cached version. It’s value doesn’t matter, but it is quite useful to use an increasing number.

1 Like

That makes sense now. Thank you very much!