CDN: Fastly or Cloudflare for Discourse sites

I saw that Meta runs and recommends Fastly but I’ve also seen on Meta that Cloudflare is also recommended.

What is truly the best option for a discourse-run site? Pros and Cons? Thanks.

Price doesn’t really matter for me

Cloudflare, free and it works fine.

1 Like

Cloudflare is probably less of a proper CDN than Fastly, so if you need a proper CDN I think Fastly would be a better choice.

1 Like

I signed up on Cloudflare and I updated my DNS records to match it and it says the site is active. Now is there anything to apply or is that simply all?

Have you seen this guide?

Yes, but for Cloudflare I dont see any of those 3 options highlighted.

What you’re looking for is three main settings:

  1. The origin address , which is the URL where your forum is currently located . This is where the CDN will draw all its original content from on first request.

  2. The CNAME , which is the “friendly” name for your CDN that you’ll set up in your DNS, e.g.

  3. The CDN URL , which is the “unfriendly” name for where the cached CDN assets will be coming from via the CDN’s worldwide network of distributed servers. It will look like

Then perhaps this one, specific to Cloudflare?

I placed cloudflare.template.yml at the end of the templates section in app.yml and it’s giving an error whilst rebuilding the app, saying no such directory was found.

Did the line look like this?

  - templates/cloudflare.template.yml

Ah that works. :sweat_smile: Is that all? I’m sorry I’m trying hard to understand this process but I’m not very skilled in this field.

1 Like

That’s what you’ll need for Discourse to once again see the originating IP of your users. Without the template all of your users appear to come from CloudFlare IP addresses. Cloudflare inserts the user IP in the header and the template makes that information available.

What it doesn’t do is use the CloudFlare API to flush objects from the cache, but as Discourse manages the names of files and images there’s not much risk a reupload will continue to serve the original object.

1 Like

That makes sense, like a filter.

Then what additional procedures are required to get Cloudflare to fully work with discourse?

As long as you don’t change the default caching rules nothing.

If you ignore querystrings, or try to replace uploads directly via file filesystem, then you will need to log into Cloudflare directly to expire the cache.