Search Unity

Strange caching-like behaviour

Discussion in 'Web' started by Ewanuk, Jun 15, 2018.

  1. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Strange problem:

    1) Create WebGL Build (version 1 for example)
    2) Deploy onto web server, load page, unity webgl loads as expected, great
    3) Create WebGL Build version 2
    4) Deploy onto web server, load page, version 1 loads instead of 2. Huh, that's weird, must be a caching thing or something
    5) Delete WebGL build from the web server, attempt to load page, we get an expected error, ok, good
    6) Deploy version 2 onto the web server, load page, version 1 still loads, we never see version 2.

    We've verified that:
    - The web server is not serving a cached version
    - The file it's serving is coming from the correct place we've uploaded it
    - The browser is not serving any cached data, these are 200 GET results from the server
    - This is all being done locally, so there's no CDN giving us old stuff
    - Data caching is disabled in the publishing settings
    - I cleared out IndexedDB to no effect

    Reproduced this on both Chrome and Firefox, so I doubt it's a browser quirk.

    What's going on? Does the Unity WebGL/JS do some kind of caching under the covers?
     
    Last edited: Jun 15, 2018
  2. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    did you clear the local browser cache too? i've had Chrome decide to try to load local cache version of webassembly build even though I completely changed the assembly on the server.
     
  3. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I am not sure what's the problem but I would recommend you to enable Name Files As Hashes player setting.
     
  4. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Tried that, made sure I'm actually loading those new hashed files, same issue.
     
  5. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Further developments, if I delete every file except UnityLoader.js, the unity client still loads, but it's still the old version.

    What's going on with UnityLoader.js that it's serving up an old cached version? How does it find the other files it needs?

    Keep in mind I have Data Caching disabled, and the file names set as hashes.
     
  6. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Looks like my

    UnityLoader.instantiate(..., ..., ...) call was getting the wrong .json file, and pointing at old resources.

    However, now I've corrected it, and I'm seeing this error:

    Invoking error handler due to
    Uncaught SyntaxError: Unexpected token <


    Our server is configured to serve gzip compressed content and json files, and checking the network tab in the Chrome dev tools, it's able to successfully GET all of the resource files specified in the given .json.

    What's going on?