Cloudflare Images Browser Cache TTL
Hi, I was wondering if someone could help me with why my browser cache TTL has changed on Cloudflare Images.
I used the API to change the TTL to one year, but it seems to have reverted to 2 days, which I noticed on Lighthouse. Why would this have changed itself?
I have sent the API request again to change it to a year, so I will see if it changes back, but so far it hasn't.
This was the API response:
And this is the cache-control headers:
public,max-age=172800,stale-while-revalidate=7200
2 Replies
Support AI
I'd be happy to help you with your question.
According to the Cloudflare Images documentation (https://developers.cloudflare.com/images/manage-images/browser-ttl/), the default TTL for an image is set to two days. However, you can override this default TTL by setting a custom TTL using the API.
It's possible that the TTL reverted to the default value of 2 days because the custom TTL you set using the API was not successfully applied or was overridden by another setting.
To troubleshoot this issue, you can try checking the API response to see if the custom TTL was successfully applied. You can also check the Cloudflare Images configuration to see if there are any other settings that may be overriding the custom TTL.
Additionally, you can try checking the
cache-control
response header to see if it reflects the custom TTL you set. According to the documentation, when the Browser TTL is set to one year, the response for the cache-control
header should be essentially public
, max-age=31536000
, stale-while-revalidate=7200
.
If you're still having trouble, you can try reaching out to Cloudflare support for further assistance.
It's also worth noting that, as mentioned in the documentation (https://developers.cloudflare.com/images/manage-images/browser-ttl/), private images do not respect default or custom TTL settings. If you're serving private images, this may be the cause of the issue.Sources
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
This seems to be back to a year now for some variants, so I assume once the cache resets for the others, they will also be back to one year.
I still would love to know why this reverted to two days, though, to avoid it happening again, if possible 😅