What should Browser Cache TTL be set for a static asset CDN?

What should Browser Cache TTL be set for a static asset CDN?

I’ve been debating between 4 hours and 1 month (same with edge cache ttl)

The file extensions as which could be found on the list as stated on the link from below:

It’s the value (time) how long a client’s / visitor’s Web browser should keep them in it’s cache until it requests for them again.

Usually, there are some issue when users set Browser Cache TTL to something different than “Respect Existing Headers” as far as they’re using some CMS like WordPress and doing some changes to the front-end, which modifies the CSS and JS files - without renaming them.
Once cached, be it either in a visitor’s Web browser cache (4 hours) or at Cloudflare, upon applying the changes, the visitor (even the webmaster itself) doesn’t see them just because.

In case you’re using a Page Rule with “Cache Level: Cache Everything” option, then even the HTML document get’s cached.
Therefore, if you update something the changes might not be seen immediately (except if we Purge Everything - flush the cache at Cloudflare) and/or possibly clear our Web browser cache to fetch the new document and see those new changes.

Regarding the “Edge Cache TTL”, it’s the value (time) for how long they should be kept at the Cloudflare.

I keep the Browser Cache TTL at “Respect Existing Headers” (because I’m sending the HTTP cache headers from my origin), while the “Edge Cache TTL” set for “a month”.
In case you don’t chane your CSS, JS and other files frequently, you’re good to go with for “a day”, so the files expire at client/visitor’s Web browser after 24hours and their Web browser must fetch them again (either from the Cloudflare Edge, or if it’s not in the Cloudflare Edge Cache, then from the origin for the first time, while each request to the same file after again is being served from the Cloudflare Edge until it expires, say it for example in a month or so how we selected).

1 Like

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