Solved Improve attached image performance by free Cloudflare CDN

Not open for further replies.


Local time
Oct 5, 2019

Hey @Adam
I would like to recommend to use the free Cloudflare CDN by using Cloudflare DNS & proxy and a page rule like described below.
I don't know if the forum software allows this but delivering the attachments/images via a subdomain for example would make things easier because you can cache the whole domain.

This will cache all images on the Cloudflare Edge servers for one month and in the browser for one day. Because attachments aren't editable this should be okay.
Right now the performance isn't this bad but could be better. You could ado the same for avatars.
Right now you deliver everything via Cloudflare - but haven't enforced caching/CDN for images and because they don't have an image file extension in the URL Cloudflare doesn't cache them by default.

You should add a page rule for the given paths with the following settings to enable/enforce CDN:

  • Always Online On
  • Browser Cache TTL a day (or more)
  • Cache Level Ignore Query String or Cache Everything - depends if the query strings could change the delivered content
  • Edge Cache TTL a month
  • Security Level Low - prevent Captchas on asset URLs

Right now the cf-cache-status: DYNAMIC header shows that Cloudflare hasn't cached it on the Edge Server - so it's only proxied. It should be cf-cache-status: HIT if Cloudflare CDN takes action.
I've used this as a free/reliable CDN with my own image manipulation service and the performance is incredible and it saves my server so much workload because every image is only manipulated once and after this delivered from Cloudflare CDN.

If you have any questions just ask me - I'm a Cloudflare user since years and primary the CDN via page rules is awesome.

Upvote 1
This suggestion has been implemented. Votes are no longer accepted.
Not open for further replies.