Dealing with browser cache

0 favourites
  • 14 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • 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.

  • 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

  • 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.

  • Ahh i see that they have changed that in C3... maybe the offline.js does the same thing now?

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • Well, if you have a htaccess file with:

    [quote:2mup5z7a] # 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.

  • 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.

  • I overwrite all files whenever I export, but I still seem to get an old version sometimes. I guess I need to do more tests to figure out where the issue is coming from.

  • I think the best way (not the easiest) is to configure whatever webserver you use to send the right cache control headers. But yeah it's kind of frustrating.

    https://www.mnot.net/cache_docs/ Might have some help on server configuration.

    I've experienced this issue in C2 as well. Previewing in Edge, Chrome was no problem, always got the latest version when reloading, but Mobile browsers and Safari, especially on Mobile NEVER updated unless you cleared cache completely every time. At least there is an easy fix in C2. (Delete offline.appcache)

    Are you planning to host your own games? then you probably should check out server configuration.

    I only use my own server for testing privately, so I always have access to a build, and can test on different devices whenever I want.

  • Maybe this could work as well, but would be annoying as hell to add to your index file every time you export a new version.

    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-cache" />[/code:3o81q1s0]
  • Ah it's not just me then, yeah I was looking to add some kind of cache control header or something.

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