Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Controlling Browser Caching

Discussion in 'Web' started by Hypertectonic, May 30, 2023.

  1. Hypertectonic

    Hypertectonic

    Joined:
    Dec 16, 2016
    Posts:
    75
    Can someone explain how caching actually works for Unity WebGL content (and addressables)?

    Here's my issue: when uploading new versions of the project to the server, and then trying to run, the first part of the project loads, but it fails when it tries to load addressable assets. I know that I can do Ctrl+F5 to force a refresh ignoring the caches, but that's just not a viable solution for other people visiting the site.

    Ideally what I'd like is to do have a cache on (as the project is rather large), but force the browser to *always* check if it has the latest content, to prevent any issues when updating. Maybe set an expiration date for content, like a week?

    I tried disabling DataCaching in the build settings but uncertain that's the issue (also... I *do* want caching... just not *always*). I also checked the caching settings in the addressable bundles. I'm confused how the WebGL build settings relate to those settings, if at all, and as usual the Unity documentation is woefully inadequate.

    Apparently there are also different ways to control the caching from html, though it is not entirely clear to me how that works or how to go about doing that, I was a bit confused when I was trying to find some information about it.

    I found this in the docs https://docs.unity3d.com/2022.1/Documentation/Manual/webgl-caching.html but it might as well be animals growls, I didn't really grasp what the example does or how to actually use it.

    So anyone can explain this stuff like I'm 5?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,553
    Could you explain the failure more? It would help to know more about the actual issue. Also why you are uncertain whether disabling DataCaching resolves the issue - does it or does it not prevent the loading issue?

    The extreme test for this issue would be to implement the loader code you linked with that function always returning no-store to disable caching of addressables.