Hi, thanks for PIXI.js! I am hopefully missing something simple.
I want to click a key and have the latest version of an image pulled from disk (for my current testing purposes) or possibly a web URL (eventually). I have an offline webpage that is using PIXI.loader.add(["file_1.jpg", "file_2.jpg"]) and PIXI.loader.load().
I have tried using PIXI.loader.reset() and then calling add() and load() again. I have also tried PIXI.utils.clearTextureCache() and/or PIXI.utils.destroyTextureCache(). No matter what, after the reload, the old version of the image file still exists until I reload the webpage itself (e.g. by pressing F5).
Create a simple offline PIXI.js v4 script with PIXI.loader.add(["file_1.jpg"]) and PIXI.loader.load(). Add a key trigger to call PIXI.loader.reset(), add(), and load().
Create a sprite from this texture.
Display the sprite.
Open an image editor, modify the image, and save it to the same file. Press the key that triggers the reset and reload. You should still see the old version of the image.
pixi.js version: 4.8.2Check if browser makes that network request and what your web-server answers to it (200 or cached?)
Try disabling your browser cache when the dev tools open.
If that solves the issue, you can add a query-string parameter to bust the browser cache file_1.jpg?v=1 or "file_1.jpg?t=" + Date.getTime(). Even though this is the same file, adding a querystring parameters considers that a separate network request.
Our PIXI loader allows setting a query string for all assets loaded through it.
So I'd do something like
loader.defaultQueryString = '' + Math.random();
for when developing an application and
loader.defaultQueryString = '' + appVersion;
for a release build.
Great suggestion @themoonrat, wasn't familiar with that feature. Super handy!
@ivanpopelyshev @bigtimebuddy @themoonrat thanks for the clever suggestion! I still needed to reset Sprite.texture for all of my sprites even though the new textures had the same name, but otherwise the query method ("?x=whatever") worked perfectly even on a filesystem.
I also want to try the defaultQueryString solution. I haven't found it in the loader documentation, but I see it in the source code.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.