Hey all,
We currently have a Unity3D webplayer game (~50MB) running as a test app on Facebook. We are noticing that the game is not being cached on the client and consequently it is being downloaded every time. We verified from our CDN that the .unity3d file has Cache control max-age set to 1 month as well as an etag. However when monitoring the requests transmitted from our browser the header does not contain neither the if-last-modified or the etag resulting in a status code of 200 rather than 304 (not modified).
When I tried to manually inject those values, the status code returned was 304 as expected. We also tried to access the Unity game directly via a normal HTML file (hence bypassing Facebook) but the problem still persists. We then tried with a much smaller build ( < 1MB) and it works on Firefox but not on Google Chrome. Here are the request and response headers being transmitted from Firefox and Chrome respectively.
Firefox
https://d11xcx539hy4uu.cloudfront.net/webplayer/Demo.unity3d
GET /webplayer/Demo.unity3d HTTP/1.1
Host: d11xcx539hy4uu.cloudfront.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: Unity Web Player | TestHTMLInjection
Cookie: __utma=1.816252137.1430129711.1430129711.1430129711.1; __utmb=1.0.10.1430129711; __utmc=1; __utmz=1.1430129711.1.1.utmcsr=d11xcx539hy4uu.cloudfront.net|utmccn=(referral)|utmcmd=referral|utmcct=/webplayer/Demo.html
Connection: keep-alive
If-Modified-Since: Mon, 27 Apr 2015 09:49:46 GMT
If-None-Match: “7c0ec58844ba4840c072f192031fd2a6”
Cache-Control: max-age=0
HTTP/1.1 304 Not Modified
Connection: keep-alive
Date: Mon, 27 Apr 2015 10:31:35 GMT
Cache-Control: max-age=2592000
Etag: “7c0ec58844ba4840c072f192031fd2a6”
Server: AmazonS3
Age: 1847
X-Cache: Hit from cloudfront
Via: 1.1 aeafa3db4617a306a1d43a9e2c98afad.cloudfront.net (CloudFront)
X-Amz-Cf-Id: ioGSb2cRd3ta1wZZjOh6j-pH-VyIL2IgcPtGZxtrefdHOC9bD9N2lA==
Chrome
GET /webplayer/Demo.unity3d HTTP/1.1
Host: d11xcx539hy4uu.cloudfront.net:443
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: __utma=1.1320335971.1430123147.1430123147.1430127793.2; __utmb=1.0.10.1430127793; __utmc=1; __utmz=1.1430127793.2.2.utmcsr=d11xcx539hy4uu.cloudfront.net|utmccn=(referral)|utmcmd=referral|utmcct=/webplayer/Demo.html
Referer: Unity Web Player | TestHTMLInjection
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=2592000
Content-Length: 89524
Content-Type: application/octet-stream
Date: Mon, 27 Apr 2015 10:00:49 GMT
ETag: “7c0ec58844ba4840c072f192031fd2a6”
Last-Modified: Mon, 27 Apr 2015 09:49:46 GMT
Server: AmazonS3
Via: 1.1 a0599354924210c43a9f77e744cf7836.cloudfront.net (CloudFront)
X-Amz-Cf-Id: WQNpaGpUp2Md9hm05z8OR947hkt9layCLMasjX1a1gakbaAvhsPOgg==
X-Cache: Miss from cloudfront (PS SOMETIMES THIS IS A HIT BUT STILL STATUS CODE 200 RATHER THAN 304)
Is there a way around this? Can we force caching via certain headers for both small and large files? Are we missing something?
P.S. We are aware of the deprecation of Unity Webplayer on Google Chrome, however this build will be available within the next few days and after that we will be shifting towards a WebGL build.