GCP CDN不缓存数据 [英] GCP CDN not caching data

查看:116
本文介绍了GCP CDN不缓存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经在GCP VM上部署了我们的网站,并在VM前面启用了GCP CDN。在大多数情况下,当我们浏览网站时,GCP CDN向Origin VM发出请求。

We have deployed our website on GCP VM, and enabled GCP CDN in front of the VM. When we browse website in most of the cases GCP CDN making requests to the Origin VM.

我正在使用下面的堆栈驱动程序查询来检查缓存命中。

I am using below stack driver query to check the cache hits.

resource.type="http_load_balancer"
resource.labels.forwarding_rule_name="rule_name"
httpRequest.serverIp="gcpvmip"
httpRequest.requestUrl="request_url"
httpRequest.cacheFillBytes > 0


推荐答案

根据您的最新评论,听起来像您期望从Cloud CDN的缓存中获得对您网站的所有请求,而无需与您的原始服务器联系。但是,使用CDN时看到缓存未命中是很正常的。每个CDN都运行许多高速缓存,而不是一个大的全局高速缓存。一个URL的内容已插入到一个缓存中这一事实并不意味着该内容将出现在所有地方的所有缓存中。此外,通常会从缓存中逐出不受欢迎的缓存条目,以便为更多受欢迎的内容腾出空间。

Based on your latest comment, it sounds like you're expecting all requests to your site to be served from Cloud CDN's caches without contacting your origin server. However, it's normal to see cache misses when using a CDN. Each CDN operates numerous caches, not one big global cache. The fact the content for one URL has been inserted into one cache does not mean it will be present in all caches everywhere. Further, unpopular cache entries are routinely evicted from cache to make room for more popular content.

以下是Cloud CDN文档的一些相关摘录:

Here are some relevant excerpts from the Cloud CDN docs:


Cloud CDN在世界各地使用缓存。缓存
是反应性的,因为如果
请求通过该缓存并且响应是可缓存的,则将对象存储在特定的缓存中。存储在一个缓存中的
对象不会自动复制到其他
缓存中;缓存到缓存的填充仅在响应
客户端发起的请求时发生。

Cloud CDN uses caches in numerous locations around the world. Caching is reactive in that an object is stored in a particular cache if a request goes through that cache and if the response is cacheable. An object stored in one cache does not automatically replicate into other caches; cache-to-cache fill happens only in response to a client-initiated request.

https://cloud.google.com/cdn/docs/overview


请注意,到期时间是缓存
条目保持有效时间的上限。无法保证缓存条目将
保留在缓存中,直到过期。

Note that the expiration time is an upper bound on how long a cache entry remains valid. There is no guarantee that a cache entry will remain in the cache until it expires.

https://cloud.google.com/cdn/docs/caching


不过,请注意,Cloud CDN在
世界范围内运行大量缓存,并且通常逐出旧的缓存条目以为
新内容腾出空间。结果,作为正常操作的一部分,每个资源需要多个缓存填充。

Note, though, that Cloud CDN operates numerous caches around the world, and old cache entries are routinely evicted to make room for new content. As a result, multiple cache fills per resource are expected as part of normal operation.

https://cloud.google.com/cdn/docs/support#low-hit-rate

如果您发现热门内容的缓存命中率较低,则最后一个链接中的建议会有所帮助。

If you're seeing low cache hit rates for popular content, that last link has suggestions that should help.

这篇关于GCP CDN不缓存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆