Cloudflair image TTL time

I would recommend moving these to be under your own domain, at which point you can use something like Transform Rules.

You’ll currently be using the dedicated imagedelivery.net domain but all of your images are actually available under your website in the /cdn-cgi/imagedelivery path.

As an example, here’s a blob: https://imagedelivery.net/kdRbTDgaPUHq8PGsHZ1fKA/4d263d6d-cdb6-4781-fe91-a4a45ee1bc00/public

If I wanted to serve this under my domain, it would be https://kian.org.uk/cdn-cgi/imagedelivery/kdRbTDgaPUHq8PGsHZ1fKA/4d263d6d-cdb6-4781-fe91-a4a45ee1bc00/public

Pretty much just replace https://imagedelivery.net/ with https://example.com/cdn-cgi/imagedelivery/

Now that it’s under your domain, your zone’s rules will apply to it. As an example, here’s the default Cache-Control header.

image

We can now create a Transform Rule to modify the Cache-Control response header that’ll allow us to set a much longer cache on the browser. You can create these here: https://dash.cloudflare.com/?to=/:account/:zone/rules/transform-rules/

31536000 translates to 1 year, the maximum value. You can read about the other options available in the Cache-Control header here: Cache-Control - HTTP | MDN

Now if we check that image again, it has the Cache-Control value that we set.

image

Maybe not ideal - but it works.

2 Likes