Can I force browser to clear cache after publishing changes?

0 favourites
  • 10 posts
From the Asset Store
Publish and Subscribe to events in event sheets and from the scripting interface
  • Hello ...

    I've noticed that when I publish my project to my server, even if I hit browser reload, it still uses cached game data, requiring I clear my own cache before seeing the changes I published.

    Is there any way in C2 to force the client to get the new game data?

    Many thanks!

  • There is only one method im aware of to accomplish this but I dont think C2 has any ability to do this. The trick is to append a parameter/string to the file name in the script tag (assuming your hosting your files) and change it when you file changes.

    Example:

    <script src="myfile.js?version=1.0"></script>

    The browser interprets the whole string as the file path even though what comes after the "?" are parameters. So next time you update your file just change the number in the script tag on your website (Example <script src="myfile.js?version=1.1"></script>) and each users browser will see the file has changed and grab a new copy.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sounds like a great trick! ... For clarification, do you mean editing the resulting index.html file and change this:

    <script src="c2runtime.js"></script>

    to

    <script src="c2runtime.js?version=1.1"></script>

  • You got it.. just change the version number every time you publish a new version of the game and the browsers will grab the new file instead of using a cached one.

  • Thanks you just saved a life ErekT

  • Keh..?

    You're welcome, whatever I did

  • I have used the above to get Kongregate to grab the newer files but recently it started giving me a black screen. I was wondering if there is anything else I could try now. As far as I know I have done nothing different to the index.html or anything else. Only change that has occurred is upgrading to newest (stable) version of Construct 2.

  • Hello ...

    I've noticed that when I publish my project to my server, even if I hit browser reload, it still uses cached game data, requiring I clear my own cache before seeing the changes I published.

    Is there any way in C2 to force the client to get the new game data?

    Many thanks!

    you can make a button on your project to clear all data...

    is you use webstorage, just "on click > clear all webstorage data"

  • Isn't there a way inside Construct? The game is supposed to automatically update itself (which can be monitored using the browser plugin), but for some reason it doesn't always work... It's really sad and annoying when one can't even rely on the official way of doing things.

  • HTML meta tags wouldn't fix mine, I had to use prodjex.com/2018/03/how-to-force-a-browser-to-clear-cache-in-web-code Busted! plugin for Wordpress.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)