File Caching

SandBoxd uses a CDN (Content Delivery Network) behind the scenes to deliver your game files to the end user. In order to keep things fast we set a default caching time of 1 day on all files except index.html. This is to ensure a high cache hit rate. Unfortunately this becomes a problem when you want to update your game. How do you notify the CDN that your files have updated?

Due to technical limitations we cannot perform cache invalidation from SandBoxd, so you will need to provide a new unique path for your changed files. We recommend that you add a versioning parameter when requesting your game files. IE if you have a file called game.js and you load it from your main html file, then you should request it like this: game.js?v=1. With each successive version you increment the v parameter.

TIP: Increment the v parameter from an automated build script to keep things simple.

In order to propegate versioning changes we need a starting point. It's for this reason that index.html is always fresh. In other words you can safetly update index.html and clients will automatically see the changes. Be sure to version every file being fetched in a chain from the main index.html. For example if index.html has a script tag which loads game.js which in turn loads an image someSprite.png and you update someSprite.png, you will want to increment the version number for both game.js and someSprite.png. This is to ensure the client fetches both a fresh game.js and someSprite.png.