I'm hosting a site that serves an HTML video. My server's video response includes the header cache-control: public, max-age=31536000, immutable. Everything works on Firefox, but on Chrome and Safari I am not seeing the caching results that I expect.
My JavaScript (Angular) seeks the video to a random location at random time intervals. There are two related, but distinct, problems I'm facing:
- Chrome and Safari request a video range every time that the video seeks, even if it's already requested that range. That means that if I leave the browser open, it will never stop making requests.
- Chrome and Safari don't cache the video between page loads.
I suspected that the problem lies in the size of the video (170 MB), so I substituted it with a smaller video (9 MB) for testing purposes. The shorter video experiences none of the problems that the longer video does:
- If the video is not cached. Chrome and Safari make only one request. They do not make new requests for every seek.
- After the first request, Chrome and Safari cache the video for new video requests.
The request/response headers are the same for the two videos, and all the responses have 206 statuses. The only significant difference I can find is that the smaller video usually takes only 1 request to download, whereas the bigger video takes multiple.
Why am I unable to cache the bigger video? How do I get around it?