Can I force browser to clear cache after publishing changes?

Get help using Construct 2

Post » Thu Jul 10, 2014 6:09 pm

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!
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Thu Jul 10, 2014 7:36 pm

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.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Thu Jul 10, 2014 10:33 pm

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>
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Thu Jul 10, 2014 10:48 pm

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.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sat Oct 18, 2014 9:47 pm

Thanks you just saved a life @ErekT
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Mon Oct 20, 2014 7:33 pm

Keh..?

You're welcome, whatever I did :)
B
39
S
16
G
6
Posts: 542
Reputation: 7,617

Post » Tue Dec 02, 2014 4:19 am

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.
B
6
S
1
Posts: 36
Reputation: 452

Post » Tue Dec 02, 2014 10:29 am

kbtbc wrote: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"
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Wed Dec 03, 2014 5:15 pm

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.
B
11
S
3
G
3
Posts: 206
Reputation: 2,379


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo, dop2000, lahbach, ST314 and 21 guests