I'm having a trouble with a video that is located in my web apache server.
This video I'm loading it on the index php page, but the problem is that it take too many time to load the video and start to reproduce.
Well, there's any way to load this video in a server cache, so that don't take too many time in load the video?
This is the code that loads the video into my html page:
<video id="mivideo" autoplay="autoplay" muted loop>
<source src="../video/video.mp4" type="video/mp4"></source>
</video>
Note; When I refresh the website in the same computer, for a couple of hours the video don't take too many time, because the web browser loads it into the cookies or local cache, but if I go to another computer, the video take long time to load, again...
Really thanks!
Server caching refers to caching remote resources on your server to prevent your server from having to download this resource everytime. Since the video is already stored on your server, and not on a remote host, there is no need for server caching here.
What you're trying to achieve here is prevent the browser from fetching the video again (which, according to you, takes a long time). This can be achieved through the Cache-Control
header. See this question (especially the .htaccess
part) for hints on how to set it with your webserver.
As a side note, if you want to make the loading of the video faster when it is not yet present on the client browser (or the cache was cleaned), you should re-encode it with a lower quality. This can be achieved with ffmpeg for example. Be careful to use an appropriate encoding to make sure your video can be played across all browsers. H.264 seems to be the only codec supported by all major browsers.