Based on this Mozilla article on Ogg media, media works more effortlessly within the browser by having an X-Content-Duration header, giving the space within minutes from the piece.

Presuming which i obtain that length saved somewhere (certainly inside a database, possibly also within the filename itself (video-file-name.XXX.ogv, where XXX it's time within minutes)), can there be in whatever way to create this extra header only using Apache .htaccess configurations? I request because loading the file right into a PHP script appears clumsy, particularly when PHP will automatically add other headers which disable caching, and will not respond correctly to range (partial content) demands. Yes, lots of code might be designed in PHP to aid ETags and range demands, however it appears like overkill to complete everything simply to add one header, when Apache has everything functionality built-in.

I do not have good examples, however, you should have the ability to use mod_header to specify HTTP Response headers in the .htaccess level.

Obviously, the question of where must i add the header really is dependent how you're being able to access it. If you're just striking a static resource for download, adding it via Apache is sensible. However, you mention a DB. If you choose to store individuals files inside a database, then you've some API supplying the file, by which situation that API implementation should append the header and never offload to apache.

Also, when the dynamic data you're wanting ever requires processing to find out (it is not within the filename or etc) then you are already with a couple code engine to attain it, just allow that to add the header.

This is actually the type of factor you need to do having a mod_perl extension, to intercept these demands and add more headers before permitting Apache to carry on handling it.

One purely PHP approach which might jobs are to achieve the demands route through PHP using mod_rewrite, add the extra header, however let Apache handle the relaxation using the virtual function.

Alternatively, you could utilize your database of trips to contruct a static .htaccess file which utilizes mod_header to place the right duration header for every asked for file.

This is actually the domain of mod_cern_meta. It enables statically setting extra HTTP headers to files.

You could utilize a cron job, and produce a *.meta apply for every video.