@teampanfu/phaser-cachebuster

1.1.0 • Public • Published

Cachebuster Plugin for Phaser 3

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.

Getting the plugin: npm and yarn

npm

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'

Getting the plugin: Directly including it.

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>

Usage

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

Credits

Contribute

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!

License

This package is open-source software licensed under the MIT License.

Package Sidebar

Install

npm i @teampanfu/phaser-cachebuster

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

9.49 kB

Total Files

10

Last publish

Collaborators

  • teampanfu