I'm setting everything up in my website to use CloudFlare.

This is my example:

On videos.domain.com/Folder-A/Folder-B/ there are some HTML files that I would NOT like CloudFlare to cache. But inside those folders, there is another one called videos, like: videos.domain.com/Folder-A/Folder-B/videos

I would like CloudFlare to cache the content in this last example URL, but not in the first one. Please note that Folder-A and Folder-B are examples and I have lots of different folders using this structure, so creating page rules one-by-one is not an option.

Here's what I've done so far using wildcards with Page Rules:

videos.domain.com/* --> Do not cache

videos.domain.com/*/videos/* --> Cache everything

Is this Ok? And also, does CloudFlare cache videos (mp4) if Cache everything is enabled?

  • Despite the accept, see Damon's (from CloudFlare) answer below. Proxying videos through CDN's is not a good idea, or recommended by CloudFlare.
    – dan
    Sep 14, 2015 at 3:35

3 Answers 3


As I posted on StackOverflow...

Assuming your video content is simply a file downloaded over HTTP/HTTPS (and not streamed over some other protocol) then it appears that CloudFlare might actually support this.

I just tested an MP4 video file on a client's website and it appeared to be cached by CloudFlare correctly.

My CloudFlare settings page rule:

enter image description here

The request (which shows a cache hit):

enter image description here

  • See the quote from CloudFlare in my answer, and comment by Damon from CloudFlare below his answer. A site can have performance issues as a result of caching streaming video content, so it's not recommended.
    – dan
    Apr 4, 2014 at 23:49
  • Would be interesting to know exactly what the problems and performance issues are caused by...
    – Simon East
    Apr 5, 2014 at 0:03
  • See the quote above: We have seen sites have performance issues because of the number of connections that streamed content causes when running through the CloudFlare proxy.
    – dan
    Apr 5, 2014 at 0:07
  • Yeah but that doesn't make much sense to me. Why would an MP4 video (for example) create an excessive number of connections in comparison to the dozens of images/CSS/JS files on a typical site? Perhaps it may have something to do with the fact that some browsers/players request the MP4 in chunks rather than the whole file at once? But surely the CloudFlare CDN would still serve these more efficiently than your average shared web host somewhere?
    – Simon East
    Apr 5, 2014 at 0:15
  • Streaming videos, which can be quite large, open multiple connections to the same resource, and each connection subtracts from the connections available to a proxy server serving that resource. I'm sure Damon wouldn't recommend against this if they could serve that any more efficiently.
    – dan
    Apr 5, 2014 at 0:23

Cache everything actually would cache everything (should be used with care).

If you are, however, streaming content on your site the advise still stands from the earlier comment by dan.

  • Thanks for the info - so CloudFlare does cache videos, even though it's not listed in your support doc here? I think there's a few questions on SE that might need updating in that case (like this one).
    – dan
    Feb 11, 2014 at 22:41
  • Thank you for the explanation. Is there no limit, then, on how much CloudFlare can cache?
    – vagaerg
    Feb 15, 2014 at 13:15
  • 1
    @Dan no, we don't cache video by default -- only if the customer manually setups a PageRule and specifically selects "cache everything". That being said, we do not encourage the caching of video content, especially if it's streaming content.
    – xxdesmus
    Mar 2, 2014 at 5:50

does CloudFlare cache videos (mp4) if Cache everything is enabled?

According to Damon at CloudFlare (see his answer below), everything is cached if Cache everything is enabled.

As indicated in the CloudFlare knowledge base article here, it's recommended to move video content to a subdomain so that it's not proxied by CloudFlare:

Sites that do streaming content, however, should move their streaming content to a subdomain we don't proxy in their DNS settings. If you created a subdomain like streams.yourdomain.com, you could then add it in your CloudFlare DNS settings like:

CNAME streams is an alias of domain.com (make sure cloud is grey).

We have seen sites have performance issues because of the number of connections that streamed content causes when running through the CloudFlare proxy.

Note: Embedded services - such as YouTube and Vimeo - would not require any special configuration because that content is being served off of your site.

Since you've already created a subdomain for your videos, you would only need to disable their proxy for that subdomain (i.e., make sure the cloud is grey), instead of setting a Page Rule.

  • Ok, thank you very much. I will move that subdomain out of CloudFlare. However, doesn't CloudFlare advise you against creating any easy to guess/easy to remember subdomain that bypassess their CDN? (for security reasons)
    – vagaerg
    Feb 15, 2014 at 13:14
  • You're welcome. You don't have to move the subdomain out, just make sure it's grayed out so it bypasses CloudFlare's network. Subdomains are visible in URLs and links to everyone, and CloudFlare adds standard/memorable subdomains like "Direct" and "FTP" to also bypass their network.
    – dan
    Feb 15, 2014 at 15:29
  • 1
    Ok, great. Thank you very much. Will disable it then
    – vagaerg
    Feb 15, 2014 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.