What is the difference between dns ttl and cache ttl?

I’ve set cache ttl to 1 month cycle.
What I’m trying to do is for cache data to change every month.
But it makes me confused that dns also have ttl settings.
Can I get the results I want if I just change cache ttl? ( My site has dns ttl setting of auto)

DNS TTL (Time to Live) determines how long a DNS record is cached before it requests the record again from your authoritative nameservers (Cloudflare), while Edge Cache TTL refers to how long your website’s static content (like images, CSS, JS) is stored in Cloudflare’s cache. Proxied Records all have a TTL of “Auto” which is 300 seconds.

The DNS TTL setting won’t affect asset cache. There’s two types of cache for your http assets. There’s Edge Cache, which can be purged anytime within Cloudflare, will be evicted from cache based on access frequency before ttl if it’s not frequently requested, and lives on Cloudflare’s edge. There is also Browser Cache which you cannot purge remotely, evicts based on various usage algorithms before ttl if not used frequently, and lives in the browser.

Setting the Edge TTL to a month would ensure no cached asset remains for longer then one month in Cloudflare’s Edge. Like I said above though, it may live far less then a full month if not frequently accessed.


thanks for your reply!

however, you said “evicted from cache” (maybe this cache is Edge Cache)
this means that if there’s no request for few minutes(or longer than this), my site makes asset cache again?

Alt-Svc: h3=“:443”; ma=86400

Cache-Control: public, max-age=2678400

Cf-Cache-Status: REVALIDATED

Cf-Ray: 85181a155ac11f13-NRT

Content-Length: 9297980

Content-Range: bytes 0-9297979/9297980

Content-Type: audio/mpeg

Date: Wed, 07 Feb 2024 02:11:23 GMT

Etag: W/“8de03c-18cd8bc0938”

Last-Modified: Fri, 05 Jan 2024 08:27:31 GMT

Nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}

Report-To: {“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v3?s=%2FyLu7aixfvWRtW0rrBcoA%2BlQ%2FhKRIE5pEfHdRU9xCScmoR0TO4uhbsJzoCZ1BjjgXIezGDbLG5imQ0aWt5gOd2AunVSzTh7NqhC%2Bc7gvWoim1WeHlIP7pi%2BxjgoK0Q%3D%3D”}],“group”:“cf-nel”,“max_age”:604800}

Server: cloudflare

Vary: Accept-Encoding

that’s my log when request mp3 file.
Is “evicted from cache” related with that’s why Cf-Cache-Status is “REVALIDATED” not “HIT”?
and i wonder this affect my origin site’s traffic.

Both Edge (Cloudflare) and Browser Cache can evict items before ttl. Cloudflare evicts items from Edge Cache based on access frequency. There’s no hard numbers on exact times, just don’t expect your assets to live for a full month unless they are popular/frequently requested.

Browsers evict assets depending on the browser, for example for Chrome: cache - How does Chrome/Chromium eviction algorithm really work? - Super User
(even if the user’s browser evicts the asset from local browser cache, they may just hit Edge Cache on rerequesting it)

Revalidated doesn’t mean evicted, it means

The resource is served from Cloudflare’s cache but is stale. The resource was revalidated by either an If-Modified-Since header or an If-None-Match header.
Default Cache Behavior · Cloudflare Cache (CDN) docs

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.