Cloudflare Images: Increasing cache TTL

Hello,

We’ve built and app that is serving images using Cloudflare Images. Everything is working fine but we want to increase the cache TTL on the images and can’t find how to do that anywhere.

Currently it seems like all images have a cache TTL of 4 hours which is a bit on the lower side. We’d want to bump this up to a few days at least.

Does anyone know if this is possible to do when only using Cloudflare Images?

1 Like

Could you post an example link of an image where the TTL is 4 hours?

Sure!

This is the URL to a demo website using our service.
https://gallery.cevoid.com/

In Google Lighthouse all rendered images report a TTL of 4 hours which Google sees as a negative and at the same time is to low of a time since the images in the galleries lose the cache every 4 hours and needs to be refreshed.

True TTL is set to 14400 (= 4 hours). Thats bad practive and since delivered from imagedelivery.net you cant even influence it by changing your settings in your dashboard.

I just red the docs and did not find a direct way to influence this. I have also never used this feature, probably for a reason.

I can confirm the issue. Asking the team…

1 Like

Yea I think it’s weird to offer a service that’s clearly meant for larger volume apps not to be able to influence the caching. It’s a new product in the cloudflare suite but I thought this was something they’d thought of.

Okay, you mean that you have you asked the Cloudflare team about being able to change this?

1 Like

Yes. It’s been passed internally to the correct team already. I have no idea if or when they’ll do something, but they got the problem to their attention.

3 Likes

It’s very unlikely for the TTL to change on the imagedelivery.net domain. That being said, did you see https://developers.cloudflare.com/images/cloudflare-images/serve-images#serving-images-from-custom-domains? Once the images are served from your domain you should be able to configure Browser TTL in the dashboard to change the TTL.

4 Likes

Alright, that’s great news! Thanks for letting me know :slight_smile:

That I didn’t know! Wow, that’s cool.

I did not see that, thanks for the link!

I will have a look at this and discuss with the team. Might be exactly what we’re looking for :slight_smile:

Yeah, seems like it, plus no additional lookup, nor domain to handle.

1 Like

Yea, cheers!

When did someone sneak that in? Last we heard, it wasn’t yet available.

1 Like

6 days ago, apparently. I wasn’t crazy to not remember it.

3 Likes

Glad this feature is live! But what other option is there to change TTL besides changing it for the entire site? That is not an ideal solution.

Use a Worker to proxy the images or use Page Rules which, should, apply. Haven’t tried myself.

I don’t think you are able to intercept mydomain.com/cdn-cgi/imagedelivery/. I have a worker with a route of mydomain.com/* and it doesn’t seem to be catching any of these image requests.

Not intercept, but proxy from a separate path to either that path or the original imagedelivery.net domain.