I want to clear the cache of all the clients who have already played my game, the stats of the game are stored in local storage, and some of my clients played the game when the stats were buggy and that data would now effect the updated stats of my game, whats the easiest way to clear the clients cache so everyone starts from scratch, i have tried to add '?v=2' this to the end of java script and CSS files but had no luck.
In general, I'd suggest to include a version number in the storage data. Eg
{
"version": 5,
"settings": {
...
When you make an update to your game's JavaScript, also associate the newly updated JS with an incremented version number by putting it in the JS.
const currentVersion = 6;
Then, in the JS, you can parse the local storage data. If the version in storage is less than the current version, you can
Since you probably don't have a version property in storage yet, you can start out by checking to see if the property exists or not yet, and if it doesn't, then you need to update.
If you use the localstorage then you can reset your data in the localstorage. I would store a versionnumber into the storage. Then you check on every request if the version is change. If yes your set the localstorage to null etc. and save the new values.