A simple Phaser Loader plugin that appends a query parameter to the URL of all loaded files to bypass the browser cache and deliver the latest version of the file.
The plugin is published on npm under @teampanfu/phaser-cachebuster
and can be installed as follows:
# npm:
npm install @teampanfu/phaser-cachebuster --save
# yarn:
yarn add @teampanfu/phaser-cachebuster
You can then add it like this:
// Assuming you use ES6 imports...
import CacheBustedLoader from '@teampanfu/phaser-cachebuster'
Paste this into the <head>
area of your HTML layout:
<script src="//cdn.jsdelivr.net/npm/@teampanfu/phaser-cachebuster@latest/dist/cachebuster.min.js"></script>
All you need to do is set the cacheBuster
variable once. You can do this for example in the preload
method:
class Preload extends Phaser.Scene {
preload() {
this.load.cacheBuster = 'my-version';
this.load.image('phaser', 'https://labs.phaser.io/assets/sprites/phaser.png');
}
}
This would result in this URL: https://labs.phaser.io/assets/sprites/phaser.png?v=my-version
- Azerion's Phaser Cachebuster for the base of the code.
If you find a bug or have a suggestion for a feature, feel free to create a new issue or open a pull request.
We are happy about every contribution!
This package is open-source software licensed under the MIT License.