简体   繁体   English

浏览器和CDN的不同缓存控制

[英]Different Cache-Control for browser and CDN

Is it possible to set different cache-control headers for CDN and browser? 是否可以为CDN和浏览器设置不同的缓存控制标头? Currently, I am using 目前,我正在使用

header("Cache-Control: max-age=3600, public");

Since, I am using public, I believe that both browser and the CDN are caching the page for 1 hour. 由于我正在使用public,因此我相信浏览器和CDN都会将页面缓存1小时。 I have origin pull set on the CDN, so that the CDN server will retrieve the page from the web host. 我在CDN上设置了源拉,以便CDN服务器将从Web主机检索页面。

I want the clients cache for 10 minutes and CDN to cache for one hour. 我希望客户端缓存10分钟,而CDN缓存1小时。 is that possible? 那可能吗?

If that is not possible, I dont want the browsers to cache the content at all, but the CDN to once every hour. 如果那不可能,我根本不希望浏览器缓存内容,而是将CDN每小时缓存一次。

It's possible, but it depends on the specific CDN. 可能,但是取决于特定的CDN。 In general, CDNs will interpret the Cache-Control header in the same way. 通常,CDN将以相同的方式解释Cache-Control标头。 The CDN has a proprietary mechanism for cache control. CDN具有专有的缓存控制机制。 For example, Akamai will read a proprietary HTTP header (X-Akamai-something) that takes precedence over standard cache headers. 例如,Akamai将读取优先于标准缓存头的专有HTTP标头(X-Akamai-something)。

It is possible to have different cache control setting for Browser and CDN. 浏览器和CDN可能具有不同的缓存控制设置。 So there are two types of cache control setting: 因此,有两种类型的缓存控制设置:

1). 1)。 Browser to Edge server cache control setting: this is usually done at Origin server and CDN usually respects that setting. 浏览器到边缘服务器缓存控制设置:通常在原始服务器上完成,而CDN通常遵循该设置。
2). 2)。 Edge server to Origin cache control setting: this is usually done at CDN layer. 边缘服务器到原始缓存的控制设置:通常在CDN层完成。 In addition, configuration can also be added at CDN layer to override that cache control setting from Origin server as in 1). 此外,还可以在CDN层添加配置,以覆盖源服务器中的缓存控制设置,如1)所示。

So in summary, you can have different cache control setting for Browser and CDN, you can also choose not to cache at Browser but only cache at CDN layer. 因此,总而言之,您可以为Browser和CDN设置不同的缓存控制设置,还可以选择不缓存在Browser上,而仅缓存在CDN层上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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