Search Unity

Question Returning visitors don't load newest version of WebGL app

Discussion in 'Web' started by Salvorite, Jan 23, 2023.

  1. Salvorite

    Salvorite

    Joined:
    Aug 1, 2013
    Posts:
    2
    I've been having an issue when I upload an updated version of my WebGL app to my Apache web server. Returning visitors who already used the app don't receive the updated version, instead loading what seems to the old version in browser cache.

    This has become a serious issue with one project where I changed the presentation format from PWA to Default. I completely deleted the folder on the web server and uploaded the new version, but returning visitors are still getting the PWA presentation page, this time with errors. It appears to be trying to load some parts of the new build, but that build is expecting the Default presentation. It's a mess!

    I've tried:

    Disabling caching in the build options in Unity.

    Adding the following to the .htaccess file in the root of the WebGL app:
    <IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
    </IfModule>


    Neither has helped.

    Note that new users, and users that have cleared their browser cache do not have any issue, however I can't ask my returning visitors to clear their cache every time there's an update.

    Any assistance is appreciated, thank you!
     
  2. kimvasquez17

    kimvasquez17

    Joined:
    Dec 19, 2017
    Posts:
    22
    I'm also facing this problem, following this thread if someone has a fix.
     
    Salvorite likes this.
  3. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    Did you try to use Name Files as Hashes from the settings? I think this should fix your problem, since there there will be no cached version of a file, if the name of that file changes due to a different hash.
    upload_2023-1-27_12-30-46.png
     
  4. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    Take a look at this :https://forum.unity.com/threads/webgl-slow-loading-after-upgrading-to-2022.1325220/#post-8383002

    and this https://forum.unity.com/threads/webgl-slow-loading-after-upgrading-to-2022.1325220/#post-8479205
     
  5. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I went through this a while back, and part of resolving it was needing to execute a line of JavaScript (shared in the thread linked below) when the page loads. My game's loading time had slowly been increasing until it was like 30s each time, but after this it went down to less than 1s (from the time the Unity logo disappears until the first scene appears). I haven't needed to do it for ages now (presumably since upgrades have been 2022.x->2022.x), but this worked in Chrome, Edge and Firefox to reset/clear the IndexedDB cache on demand:
    https://forum.unity.com/threads/increment-indexeddb-version-number.1188988/#post-7607203