Hey,
In the WebGL Publishing Settings there is a check for Data caching.
I couldn’t find any documentation on this.
What does it do exactly?
Hey,
In the WebGL Publishing Settings there is a check for Data caching.
I couldn’t find any documentation on this.
What does it do exactly?
This enables the build to use the browser cache to store its files. So returning users won’t have to download your files again.
Does this also effect PlayerPrefs?
No. How/why would it?
If I update an asset file that is already cached by browser, does the browser try to download a new asset file?
Was just trying get this confirmed, turns out the testers cleaned there browser data on reload. thanks for the response
It seems that the docs on Data Caching does not contain those information (25/06/2015):
What exactly is cached and when/how does it expire and how do we make sure new builds correctly bust the cache?
What Claytonious said, plus can we confirm Data Caching works? Delivering the compressed version of our webgl build (within Facebook Canvas) to Safari and Chrome with Data Caching checked, both browsers crash and fail to reach the default Unity preloader. Uncheck the option and our content loads.
Hi, I have problem with caching of WebGL,
I do not use Data Caching in PlayerSetting.
I set Cache Control: public, max-age=3600 for all files.
When I upload new build many users have problem to load it.
Browser gets new *.js files but it has problem with loading WebGL.data file(maybe because of diffrent content-type)
Even after 1 hour still there is error: Content-Length mismatch with file WebGL.data.
Hard refresh (ctrl+F5) fixes it, but users do not know about it.
Still UnityLoader.js is not able to load file WebGL.data when browser will return it with http status 206 partial ok
is there a url that we can check ?
Got the same problem, data caching disabled, but need ctrl+f5 (only in chrome)
Whatever issue may or may not be present in individual builds, can we address the broader question? “What exactly is cached and when/how does it expire and how do we make sure new builds correctly bust the cache?”
Thanks!
Hello Claytonious.
I believe Data caching build option requires some additional explanation.
Basically, there are two independent layers of .data caching:
Browser cache.
This cache layer is fully controlled by the browser. The behavior of the browser cache depends on the browser configuration and the headers provided by the server. Depending on the Last-Modified, ETag, Expires, Cache-Control etc. headers, the browser can either serve the previously cached response without validation, or efficiently reload it using If-Modified-Since or If-None-Match headers. The WebGL loader currently does not make use of the server provided headers, so the server response headers only affect the browser caching layer.
Optional IndexedDB cache (Data caching build option).
This is an additional cache layer managed by the WebGL loader. Each time you build your project, the .data package is assigned a unique id. This package uuid is hard-coded in the UnityLoader.js in a form of
var PACKAGE_UUID = ‘71dc6a9c-a252-4eb9-986a-4468b011729a’;
When Data caching option is enabled, the downloaded .data package with it’s associated uuid are stored in the browser IndexedDB/your-origin/EM_PRELOAD_CACHE/ location.
Now if you reload the build in the browser, UnityLoader.js will first check if the .data package with the specified PACKAGE_UUID is already present in the browser IndexedDB, in which case the .data package will be taken from the database.
Normally you can rely on the browser cache layer. But in some special cases (like if your server does not handle If-Modified-Since or If-None-Match properly, or in some other way makes browser caching mechanism unusable) you may consider enabling Data caching build option. Note that some browsers may ask the user for permission to store additional data in the IndexedDB if you exceed the IndexedDB quota.
Thanks for that detailed response. It’s very helpful. Have a great day!
I am also seeing this issue - if I update the webGL build, I will get out of memory errors, uncaught aborts, and whatnot unless the player manually clears the browser cache. I’ve tried setting cache-control to “no-cache”, expires to “0”, and pragma = “no-cache” in the index.html header, but it doesn’t seem to have any effect. Caching has been turned off in the player settings.
Did anyone on this thread who was having these issues find a solution? Thanks in advance.
Hello JanusAnderson.
Note that caching option in the player settings controls caching in the IndexedDB, which has very little to do with the browser’s response content caching (although IndexedDB can be also optionally cleaned up when user clears the cache).
If you get multiple weird errors like abort or out of memory etc. after the game update, then it is most probably the issue with your server caching configuration (which means that the client receives old versions of some content files and not the updated ones). Not only you have to ensure that the index.html is being revalidated, but also all the content files from your Release folder (i.e. .data, .js and .mem) and streaming assets (if present) should be revalidated. Note that changing the headers on the server does not necessarily imply immediate changes in the server response, as the content might be already cached by the intermediate proxy software. You can easily check if the server caching configuration is causing the issue if you append a random query to all the requested urls, which will enforce complete revalidation irrespective of the server setup. Check out the following answer for the exact procedure http://forum.unity3d.com/threads/host-update-time-after-upload.377601/#post-2451672
Hi, would it be possible to have JS code that would invalidate unity data for next loading? We think to put it next to “fullscreen” button for WEBGL where IF user encounter some weird issues caused by caching or that we updated new version on server then he/she simply click something like “Force Reload” button. Is there a JS code for that?
Can this be the solution?
self.clear =function(){
//location.reload(true); Doesn’t work to IE neither Firefox;//also, hash tags must be removed or no postback will occur.
window.location.href = window.location.href.replace(/#.*$/,‘’);
};