简体   繁体   中英

How regularly is the cached content updated from origin server in CDN?

Since most of CDNs update the cache data only after it reaches an expiry, what if the origin server is updated before that. Does the CDN serve the old data until updated upon expiry?

Generally they have a callback method for you to let them know if a content changed and needs to be updated/re-cached. So it won't serve the old content until the next refresh.

You can see the documentation for Cloudflare-Purge Cache and Azure .

Yes, the CDN will serve the older content even when the origin is updated. This is because no one really told the CDN that there is an updated asset at the origin.

There are a couple of ways you can make sure the CDN always has the latest asset cached. The easiest way is to purge the cache each time there is a new/updated asset. This can be built into your CI/CD pipeline so that there is an auto-purge each time you deploy a new version

The other way I've seen a lot of people do is to have a version as part of the URL itself. So that when the asset is updated, it would have a new version as part of the object name. So when the browser makes a request, it is automatically requesting the new object.

Hopefully, this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM