[ACCEPTED]-Under what conditions will the browser cache <video> files?-browser-cache

Accepted answer
Score: 18

The following works to instruct the browser 3 to cache the files. The last line was necessary 2 to make the server deliver webm files with 1 the correct header MIME type.

# Expires is set to a point we won't reach,
# Cache control will trigger first, 10 days after access
# 10 Days = 60s x 60m x 24hrs x 10days =  864,000
<FilesMatch "\.(webm|ogg|mp4)$">
Header set Expires "Mon, 27 Mar 2038 13:33:37 GMT"
Header set Cache-Control "max-age=864000"
AddType video/webm .webm
Score: 6

The HTML5 spec is not strict about what 20 a browser must do with caching video files 19 - it just suggests what is "reasonable", so 18 theoretically different browsers could have 17 different behaviour.

Web developers can try 16 to control video caching using the preload attribute 15 on the <audio> or <video> element like this:

preload=none The user 14 might not watch the video (i.e. better not 13 to preload)

preload=metadata The user might watch the video 12 (i.e. better to just download information 11 about the video (size, duration, etc.))

preload=auto The 10 user is likely to watch the video (i.e.probably 9 a good idea to preload and cache the video)

As 8 I said, the spec does not enforce this so 7 browsers could ignore the preload values 6 if they choose. One example could be if 5 a browser detects a slow or unstable connection 4 and therefore refuses to preload, although 3 I don't know of any browsers that do this 2 at present.

More information on the preload 1 attribute is here: http://www.w3.org/TR/html5/video.html#attr-media-preload

More Related questions