Mailing List Archive

caching of HTML5 <video> (MP4)
Hi folks,

When I'm serving up many (huge) MP4 files via HTML5 <video>, and want
heavy caching to keep traffic down, is the following suitable
public_html/.htaccess content?

=====
<IfModule mod_expires.c>
<FilesMatch "\.(mp4)$">
ExpiresActive On
Header set Expires "Mon, 27 Mar 2038 13:33:37 GMT"
</FilesMatch>
</IfModule>
=====

Thanks!

Best regards,
Norbert


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: caching of HTML5 <video> (MP4) [ In reply to ]
Anyone know a company that I can pay to get solid advice on this?

I mean a company that actually knows what to do in my situation,
instead of just accepting my money and then using Google/Stack Overflow
to see what information they can give me.

Best regards,
Norbert

On Thu, 2019-06-13 at 20:40 +0200, Norbert de Jonge wrote:
> Hi folks,
>
> When I'm serving up many (huge) MP4 files via HTML5 <video>, and want
> heavy caching to keep traffic down, is the following suitable
> public_html/.htaccess content?
>
> =====
> <IfModule mod_expires.c>
> <FilesMatch "\.(mp4)$">
> ExpiresActive On
> Header set Expires "Mon, 27 Mar 2038 13:33:37 GMT"
> </FilesMatch>
> </IfModule>
> =====
>
> Thanks!
>
> Best regards,
> Norbert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Re: caching of HTML5 <video> (MP4) [ In reply to ]
Hello, Norbert,


first of all I want to introduce my situation a bit. I am IT sysadmin at
a telecommunication who is responsible for setting up web servers. We
also have the situation that customers load a site or a part of a site,
say the CSS files or JQuery, a hundred times an hour whice is really not
necessary.

In the view of HTTP, caching is always an advice that is given from the
server to the client. It is the client's responsibility (i.e. its
specific behaviour to follow this advice) to really cache the files and
not re-request them from the server.

In HTTP 1.1, the caching is a simple HTTP header field, see section 14.9
here:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

So, for example:

Cache-Control: max-age=3600, public

to advice the client a cache of 3600 seconds. You may want to adjust the
value to your needs.

Since you do not want every file to be cached, you may want to put the
header under a condition:

<FilesMatch "\.mp4$">

Header set Cache-Control "max-age=3600, public"

</FilesMatch>

You can put this into the virtual host configuration file or into the
.htaccess file.The FilesMatch directive is described here:

https://httpd.apache.org/docs/2.4/de/mod/core.html#filesmatch

and the string "\.mp4$" is a Regular Expression to match the file names.


Kind regards,

rexkogitans


Am 16.06.19 um 09:53 schrieb Norbert de Jonge:
> Anyone know a company that I can pay to get solid advice on this?
>
> I mean a company that actually knows what to do in my situation,
> instead of just accepting my money and then using Google/Stack
> Overflow to see what information they can give me.
>
> Best regards,
> Norbert
>
> On Thu, 2019-06-13 at 20:40 +0200, Norbert de Jonge wrote:
>> Hi folks,
>> When I'm serving up many (huge) MP4 files via HTML5 <video>, and want
>> heavy caching to keep traffic down, is the following suitable
>> public_html/.htaccess content?
>> =====
>> <IfModule mod_expires.c>
>> <FilesMatch "\.(mp4)$">
>> ExpiresActive On
>> Header set Expires "Mon, 27 Mar 2038 13:33:37 GMT"
>> </FilesMatch>
>> </IfModule>
>> =====
>> Thanks!
>> Best regards,
>> Norbert
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:users-unsubscribe@httpd.apache.org <mailto:users-unsubscribe@httpd.apache.org>
>> For additional commands, e-mail:users-help@httpd.apache.org <mailto:users-help@httpd.apache.org>
Re: caching of HTML5 <video> (MP4) [ In reply to ]
Thank you very much rexkogitans.I really appreciate your feedback/info.
On Sun, 2019-06-16 at 12:20 +0200, rexkogitans@gmx.at wrote:
> Hello, Norbert,
>
>
>
> first of all I want to introduce my situation a bit. I am IT
> sysadmin at a telecommunication who is responsible for setting
> up
> web servers. We also have the situation that customers load a
> site
> or a part of a site, say the CSS files or JQuery, a hundred
> times
> an hour whice is really not necessary.
> In the view of HTTP, caching is always an advice that is given
> from the server to the client. It is the client's
> responsibility
> (i.e. its specific behaviour to follow this advice) to really
> cache the files and not re-request them from the server.
> In HTTP 1.1, the caching is a simple HTTP header field, see
> section 14.9 here:
> https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
> So, for example:
> Cache-Control: max-age=3600, public
> to advice the client a cache of 3600 seconds. You may want to
> adjust the value to your needs.
>
>
> Since you do not want every file to be cached, you may want to
> put the header under a condition:
> <FilesMatch "\.mp4$">
> Header set Cache-Control "max-age=3600, public"
> </FilesMatch>
> You can put this into the virtual host configuration file or into
> the .htaccess file.The FilesMatch directive is described here:
> https://httpd.apache.org/docs/2.4/de/mod/core.html#filesmatch
> and the string "\.mp4$" is a Regular Expression to match the file
> names.
>
>
>
> Kind regards,
> rexkogitans
>
>
>
>
>
> Am 16.06.19 um 09:53 schrieb Norbert de
> Jonge:
>
>
>
> >
> > Anyone know a company that I can pay to get solid advice on
> > this?
> >
> >
> >
> > I mean a company that actually knows what to do in my
> > situation, instead of just accepting my money and then
> > using
> > Google/Stack Overflow to see what information they can give
> > me.
> >
> >
> >
> > Best regards,
> > Norbert
> >
> >
> >
> > On Thu, 2019-06-13 at 20:40 +0200, Norbert de Jonge wrote:
> >
> > > Hi folks,
> > >
> > > When I'm serving up many (huge) MP4 files via HTML5
> > > <video>, and want
> > > heavy caching to keep traffic down, is the following
> > > suitable
> > > public_html/.htaccess content?
> > >
> > > =====
> > > <IfModule mod_expires.c>
> > > <FilesMatch "\.(mp4)$">
> > > ExpiresActive On
> > > Header set Expires "Mon, 27 Mar 2038 13:33:37 GMT"
> > > </FilesMatch>
> > > </IfModule>
> > > =====
> > >
> > > Thanks!
> > >
> > > Best regards,
> > > Norbert
> > >
> > >
> > > ---------------------------------------------------------
> > > ------------
> > > To unsubscribe, e-mail:
> > > users-unsubscribe@httpd.apache.org
> > > For additional commands, e-mail:
> > > users-help@httpd.apache.org
> > >
> > >
> > >
> >
> >
>
>
>
Re: caching of HTML5 <video> (MP4) [ In reply to ]
On Sun, Jun 16, 2019 at 12:21 PM rexkogitans@gmx.at <rexkogitans@gmx.at> wrote:
[...]
>
> In HTTP 1.1, the caching is a simple HTTP header field, see section 14.9 here:
>
> https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

The current RFC would be https://tools.ietf.org/html/rfc7234, but
https://tools.ietf.org/html/rfc7232#section-2 may also apply here.

If you're serving the same file from multiple servers, you may have to
ensure that the modification times are identical on all servers, so
that the Last-Modified Headers don't change, and possibly adjust the
way ETags are calculated (see
https://httpd.apache.org/docs/2.4/de/mod/core.html#fileetag), since
the INode numbers may be different from one server to the next.

rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org