Dealing with browser cache

Post » Wed Apr 05, 2017 10:26 am

So, I've tested this quite a lot now.

On my site, we have a htaccess file that cache images and js files, so you can likely gather the problem already. Since Construct uses JS, people won't get a new version of the game files unless they do a hard refresh.

Short of manually editing the index file in generates each time to force no cache with PHP, are there other ways to ensure if they game has changed that people get the latest version?

One possible way, would be to have the index.html file add a ?v= string to the js files that have been updated and increment it maybe by the date and time or the version set in the project settings? Would be simple and wouldn't require any real effort from users.
Last edited by liamdawe on Wed Apr 05, 2017 10:43 am, edited 1 time in total.
B
4
S
2
G
5
Posts: 346
Reputation: 2,417

Post » Wed Apr 05, 2017 10:40 am

You can delete the output file. "Offline.appcache" and it will automatically refresh every time you reload. I always do this, but it's a bit tedious to manually delete that file every time you export a new version. I would love for the have it as an option in export, just so I don't have to manually delete that file every time :p
Last edited by tunepunk on Wed Apr 05, 2017 10:45 am, edited 1 time in total.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 945
Reputation: 12,212

Post » Wed Apr 05, 2017 10:42 am

tunepunk wrote:You can delete the output file. "Offline.appcache" and it will automatically refresh every time you reload. I always do this, but it's a bit tedious to manually delete that file every time you export a new version.

Is this something in the browser, or the games folder, as I don't seem to have one.
B
4
S
2
G
5
Posts: 346
Reputation: 2,417

Post » Wed Apr 05, 2017 10:48 am

Ahh i see that they have changed that in C3... maybe the offline.js does the same thing now?
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 945
Reputation: 12,212

Post » Wed Apr 05, 2017 10:49 am

The caching is actually done locally by the game using a service worker. (This is the same is it is done now in C2.) It does cache-busting when updating to bypass any server settings, so the server configuration probably doesn't affect anything.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Wed Apr 05, 2017 11:02 am

Then the system you have in place doesn't really work, nearly every time I update my game and load it, it's either an old version of a mix of both so it's broken.
B
4
S
2
G
5
Posts: 346
Reputation: 2,417

Post » Wed Apr 05, 2017 11:44 am

There's a lot of levels of caching between you and the server (lots!) We're getting a few bugs which we're dealing with as they come up. Caching bugs are pretty tricky to deal with but bear with us I think we're nearly there.
Image Image
Scirra Founder
B
160
S
41
G
34
Posts: 4,387
Reputation: 53,516

Post » Wed Apr 05, 2017 11:46 am

I think @liamdawe is talking about exported projects?

If so it depends on a lot of things, including the particular browser you're using. C3 uses the same system C2 does, but without the older AppCache support. I'll need a lot more information about the setup, repro steps and so on to be able to investigate further.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Wed Apr 05, 2017 11:49 am

Well, if you have a htaccess file with:
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES

And your exported game is inside a folder that has that htaccess at the root (tons of sites use this), the JS files to run the game will be in a cache you have to either force to expire by doing a hard refresh, or mess with the index file to add a version string to the JS files.
B
4
S
2
G
5
Posts: 346
Reputation: 2,417

Post » Thu Apr 06, 2017 9:12 am

The Service Worker forces an update bypassing the cache, providing you export again from Construct and overwrite offline.js as well as the other files.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Next

Return to General Discussion

Who is online

Users browsing this forum: scirrakeen, sizcoz and 2 guests