How do HMTL game updates work?


#1

Hi, I would like to clarify how HTML game updates are handled.

If I upload some HTML game online and play it, I notice that the whole game is stored in the browser’s cache and I am able to close the browser, come back later, and when opening the page again, the game starts up without downloading most, if not all, of the assets again. The loading screen is often instantaneous.

This suggests that the game stays on the user’s browser until the cache is cleared. If so, how would updates to the HTML game work when I make changes to certain areas of the uploaded game?

Is there a way to ensure that a user will always be pushed the new changes (especially for changes within existing scenes where the output “codeXX.js” file name stays the same)?

Does GDevelop have a check that perhaps looks at the timestamp of the output files and updates them with new ones? If not, what would be a best practice to force changes to existing files?

Thank you for any info anyone may have.


#2

Updates should apply without issue, from what I’ve seen from stuff like Itch.io and GameJolt.

Save data uses the browser’s “Storage” system, so that should not be wiped even if you update the game.

Someone with more knowledge around the infrastructure of the HTML deployments would need to chime in to be more specific, though.


#3

I always just make use of a query string. If you’re able to edit the index.html file that GDevelop creates, I go through and add “?=xx” to the end of all the JS files. For example:

<script src="runtimegame.js" crossorigin="anonymous"></script>

would become:

<script src="runtimegame.js?=2" crossorigin="anonymous"></script>

Then each time I update, I increase the number.

You can put whatever you want after the question mark. This allows you to have the same file name, but give it a “version”. If what’s after the question mark is different the next time the browser loads the page, it will not load the cached version and instead load the new version. Ensuring when players load your game they will get the newest files.


#4

Thank you for the suggestion. I never thought to use query strings that way.