Image not updating without manually purging the cache on Cloudflare

What is the name of the domain?

What is the error number?

N/a

What is the error message?

N/a

What is the issue you’re encountering

When I change an image, it seems that the only way to see the new image is to purge cloudflare cache

What steps have you taken to resolve the issue?

I have to copy the image URL for example https://www.folkandhoney.co.uk/img-venues/venue-1762-1.jpg
then Cloudflare>configuration>caching> custom purge with the image URL

If the image is served from cache you would expect to only see it change when the cache expires or is flushed.

Yes that seems logical, but usually an image would be in the local cache. In my case even if the user has never visited the page before, he will still see the old image.
I am new to Cloudflare and I have never experience this kind of problem in the past. Is there a configuration I should change?
My curent settings in caching are:
Caching level - standard
Browser cache TTL - 2 min.

Cloudflare is a CDN so is caching your content at its data centres, that is how is speeds up your site for your visitors. Have a read of these…

https://www.cloudflare.com/en-gb/learning/cdn/what-is-caching/

1 Like

Yes, I understand the concept of speeding up the website with caching.
However, shouldn’t Cloudflare “know” when an image has been updated?
Or are you saying that every time an image is updated on my website, I need to manually log in to Cloudflare and purge the cache for that image?
Or eventually create a rule as per the article you sent me. To be honest, I don’t know what kind of rule I should create.

How can it? It would have to go back to your origin to check on every request and that would defeat the point of caching in the first place.

No, the cache has a time limit (the TTL) and when that is reached, Cloudflare reaches back to the origin to update the asset so if you make a change then it will make its way to users some time later.

Also, storage is limited so rarely used assets may be purged from the cache sooner depending on how busy your site is.

In the links above you will see where the default Cloudflare behaviour is defined and how you can change it if you want so the asset is not cached, or is cached for a longer or shorter period. Or you can manually flush the cache or write some code and use the Cloudflare API to automate this.

If your site uses Wordpress you can use Cloudflare’s APO to automate the flushing of the cache when you make changes.

I got you, the issue I have is that the user can update an image himself, so if he doesn’t see the new image (that what is currently happening) he think the change din’t work.
Do you think that in my case I would need to tell Cloudflare not to cache the images? That would be a shame isn’t it? But maybe I have no choice

When your back end receives the uploaded image add some code there to call the Cloudflare API to flush the cache for that URL so the process is fully automated. Then you can cache long while being able to serve updated assets immediately.

Unfortunately I can’t update the website code.

Thank you for your help @sjr FYI, I end-up creating a rule to bypass the cache for the folder containing the images that the user can update.
that’s the expression:
(http.request.full_uri wildcard “https://www.folkandhoney.co.uk/img-artists/*”)
Probably not the best, but It does work.

It would probably be better to set Edge Cache TTL for ~5 minutes, and inform users “Please allow five minutes for all changes to appear on site.”

That way, if your site ever gets hammered due to some sudden attention, your server won’t suffer an overload.

hmmm, I installed cloudflare because the bandwidth usage for my website was too high!
How do you make that? I tried to setup a cache rule, but it doesn’t seems to work

You already have the cache rule in place. You just need to change “Bypass cache” to be “Eligible for cache,” and set Edge TTL to “Ignore cache-control header” and 5 minutes:

Thank you, i was doing that, but somehow it is not working.

Can you be more specific?

The image is not updating after 5 mins when i refresh the browser

At this time, I can not reproduce, since they’re all currently bypassed. Can you set one specific image to have an Edge TTL of five minutes, so we can test it?

This one: https://www.folkandhoney.co.uk/img-venues/venue-85-1.jpg
It has an edge of 10 sec. but it is not updating.
I have deactivated the bypass rule for now


for me

Refreshing on the link that you shared, here’s what I see:

1.

cache-control: max-age=2592000
cf-cache-status: MISS
date: Sun, 13 Apr 2025 17:33:31 GMT

2.

cache-control: max-age=2592000
cf-cache-status: REVALIDATED
date: Sun, 13 Apr 2025 17:34:41 GMT

3.

cache-control: max-age=2592000
cf-cache-status: REVALIDATED
date: Sun, 13 Apr 2025 17:35:01 GMT

While I have to admit that the requests aren’t exactly 10 seconds a part, -

REVALIDATED means that that the Edge (e.g. Cloudflare) requested (e.g. revalidated) the image again from your origin.

So the edge TTL, and the cache at the Cloudflare edge for 10 seconds, appears to work just fine, if you’re asking me.

The huge Cache-Control with max-age=2592000 (seconds, which are translating to 30 days) is likely the culprit here, as it is instructing browsers that they may cache the image for up to 30 days.

My suggestion will be to look in to the Cache-Control header as well, to make sure that it fits your needs as well.

If I’m understanding your thread well, you’re likely looking for:


Edge TTL

  • Ignore cache-control header and use this TTL

  • TTL: 5 minutes

Browser TTL

  • Bypass cache

This way, Cloudflare should remember your image for 5 minutes, and won’t get instant updates (but first after 5 minutes).

Browsers (Firefox, Chrome, …) will always ask Cloudflare, and will see the update as soon as Cloudflare does.

Note: For browsers that have already seen max-age=2592000, chances are that the damage may already have been done, and you may unfortunately have to clear the browser cache, or alternatively wait out the full 30 days, for it to take effect on that specific browser, if you cannot get the individual visitor to “hard refresh”.

1 Like

I’m a bit lost here:
When I setup a rule for cloudflare not to cache the images - it’s does work , when I test I can see the new image almost immediately after changing it.
If I have a rule to wait for a time period, it seems that now the browser caching the image bring some issues. I don’t get where this 30 days is setup and what to do with the cache control header.