Search Unity

Question Files always get invalidated on WebGL when must-revalidate is used

Discussion in 'Web' started by xAdamQ, Apr 23, 2023.

  1. xAdamQ

    xAdamQ

    Joined:
    Jul 23, 2016
    Posts:
    53
    Code (CSharp):
    1.  if (url.match(/\.data/) || url.match(/\.bundle/)) {
    2.           console.log("cacheControl returning must-revalidate for url: ", url);
    3.           return "must-revalidate";
    4.         }
    When I use "must-revalidate", or leave the cache control config as default, the ".data" and ".bundle" files always get invalidated and redownloaded again. It only uses the cache when I change it to "immutable:.
    The etag and last-modified header have the same values.

    The cache control response header from my server for these files is: "public, max-age=1296000, no-cache"
    So, is this an issue with my server headers or is it a webgl thing?

    Also can you please give me a source to understand how Unity WebGL cache works? for example how "must-revalidate" knows that the file was changed? does it have a lifetime or not?

    Here is the game: tuxul.com
     
  2. xAdamQ

    xAdamQ

    Joined:
    Jul 23, 2016
    Posts:
    53
    and does unity ask the WebGL cache for the files before making a request? (Which leave it to the browser). because when I set it to immutable, there is no web request at all.
     
  3. xAdamQ

    xAdamQ

    Joined:
    Jul 23, 2016
    Posts:
    53
    HEYY, ANY IDEA?
     
  4. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    288
    Unity WebGL's cache function uses IndexedDB.
     
  5. xAdamQ

    xAdamQ

    Joined:
    Jul 23, 2016
    Posts:
    53
    It seems like it's Unity's problem since this consistent across all browsers.