How to force CloudFlare to cache all MP4 files?

We have a Social site behind Cloudflare proxy in Pro plan where users can upload short videos in MP4 format.

Rendering those videos slow down a lot our pages. So I’m wondering how can we make Cloudflare to cache all the MP4 files?

Appreciate your help in advance.

Videos are uploaded and played on our forum. They are numerous and added regularly by users not by admins. So I’m not sure how Cloudflare Stream can be helpful in this scenario.
Isn’t there any other solutions to instruct Cloudflare to cache and deliver ON-SITE videos?

Cloudflare caches .mp4 files of a size up to 512mb by default.

What exactly is your problem? Is your server overloaded because of the video downloads, are does the site render slowly because the videos need to be downloaded completely before they become playable?

Can you maybe provide a link that shows your problem?

Our server’s bandwidth is capped and I suspect it is mostly due to videos.
The videos are in html format. like so:

<video controls=""> <source src="/path/to/video/user123/vid.mp4" type="video/mp4"> my funny video</video>
How can I check whether the videos are cached and rendered by Cloudflare rather than the sever itself?

For Chrome, open the dev tools with F12, go to Network and check “Disable Cache”.

Then reload with ctrl + r, find the file you want to check, go to Headers and look at Cf-Cache-Status in the Response Headers section.

2 Likes

I get Cf-Cache-Status: HIT for the vid.mp4

Does this mean that the video is fully served by Cloudflare?

Yes, exactly.