Video Caching Returning 206 on AEM Manager running on Apache Server

We are facing issues while trying to cache video on the AEM Dispatcher. We are running Manager 4.1.2 on Apache 2.2 HTTP Server.

Videos are rendered correctly and work in all browsers, however they are NOT cached when viewed from Chrome / Firefox, however they are cached properly when viewed from IE. The difference between browsers is that when a user opens a video in IE, it first downloads the full video and then starts playing and therefore returns 200 as the response code. When chrome / firefox plays a video it uses a range request and the full video is loaded by the browser in multiple range requests returning 206 as the response code.

This is all I know so far and I suspect due to partial requests made by chrome / firefox the dispatcher is not caching the video.

Any pointers for solving this problem would be really helpful!

+3


source to share


1 answer


However, we personally skipped video caching on the dispatcher as we now use a CDN to cache videos, but if anyone is interested in caching video on the dispatcher, here is a suggested solution that I haven't implemented yet but should work in theory.

Working with video caching based on browser behavior: The dispatcher is used to cache items like images / pages / videos, etc., and there are certain conditions under which the dispatcher caches the content it serves, one of which is the response code must be 200. Now that videos are played in different browsers, it takes a different approach to play videos.

When a video is played using Chrome and Firefox, it uses a partial content strategy to download and play the video, that is, it sends a request to the server to get only a part of the video to quickly start playing, in which case it sends the range header with a request that returns part of video with status code 206 (success with partial content). So, to play the video, the browser (Chrome and Firefox) makes a multiple range request, each of which returns a 206 status code and has a portion of the video, which prevents the video from being cached when accessed through those browsers. The browser manages to play all the videos by combining these parts.



Now, in the case of IE, the behavior is slightly different. Instead of making requests for a partial range, it makes a request to download the full video first, and only after the entire video has been downloaded does it start playing the video. Thus, in this case, the server returns a video file with a status code of 200, which the dispatcher sees as being cached and therefore caches the video. Therefore, when the video is played by IE browser, it will be cached due to this behavior.

Possible Solution: Therefore, based on the behavior described above, videos when played from Chrome / Firefox will not be cached on the dispatcher, while the same videos when played from IE will be cached. Now, if we still want to make a cache video, regardless of the browser in which it is played, we have to mock the behavior of IE's video download requests by implementing a special piece of code called Cache Warming Script. This script will not change browser behavior. This script will run immediately after the video is activated by the author, which will trigger a reset event for the dispatcher for this video, and we will catch this event and run our Script. This script will make a request to download the full video with the same titles that IE uses,that is, in turn, it will automatically cache the video on the dispatcher. So, all we do is cache the video right after it is published, and not wait for it to be cached when it plays through the browser.

0


source







All Articles