Currently, it's possible to transparently set a cookie in the client’s browser to automatically enable “HTML5 mode” when visiting youtube.com. This can present a major advantage, since with the new HTML5 video content type it's easier to cache YouTube videos without any need for RTMP proxy or more complex CPL code.
“Videos with ads are not supported (they will play in the Flash player)”
This means that the same video may sometimes play in Flash because an ad will be displayed. Other times it will play in HTML5. There is no possibility in controlling this until YouTube enables HTML5 for their advertisements also.
Ensure that the proxy is intercepting HTTP traffic. Add the following CPL code to your local policy file (see comments inline):
;if the HTML5 preference cookie is not present, instruct the client to set this cookie
url.host.substring=youtube.com request.header.Cookie=!".*PREF.*f2.*" action.set_HTML5_cookie(yes)
;by detecting if the HTML5 “video” content is detect, force the proxy to cache this HTTP object
define condition html5_video_tag
define action set_HTML5_cookie
set( response.header.Set-Cookie, "PREF=f2=40000000; path=/; domain=.youtube.com;" )
How can you tell if the above policy works and the browser is using HTML5 mode?
Using the browser, navigate to http://youtube.com/html5. Even though the client never “opted-in,” you should see this:
How can I tell if a specific video being played is actually using HTML5?
When viewing the video, right click on the video. If the video is using the normal Flash you will see a Flash context menu:
On the other hand, if the video is using HTML5, the menu will relate to HTML5:
How can we see the caching gains that HTML5 introduces?
This can be seen in the Active Sessions report on the ProxySG (Statistics > Sessions > Active Sessions). The first time a video is accessed in HTML5 you will see no gains; this is expected:
However, the second time a user requests this video, you should see 80-100% savings:
Note how the proxy is serving the object from cache.
- Even with the above CPL in place, browsers that do not support HTML5 will not break. They will simply fall back to the Flash Player.
- The first time a user requests a video in HTML5, there may be a longer delay than normal in serving the video than when accessing the video in Flash:
This is to be expected because the proxy is requesting the video from the server and must wait until it completely caches the object before serving it to the client. However, once past this stage, the video is fully buffered, as will be subsequent visits to the same video. The delay depends on the speed of the WAN link and the size of the video.
- Ensure that the Do not cache objects larger than setting is not set too low:
Some of these videos can get quite large, so make sure to find a balance between what you need to cache and what is considered too large to cache.
- This may change in the future, but until now streaming video remains using Flash or RTMP, so there are no splitting benefits or similar.