Nginx 代理显示旧内容

问题描述

我的设置存在一些问题,其中包含: 代理 -> CDN 缓存 -> Origin。

它的设置是为了如果我们更新源上的内容,我们会清除 CDN 缓存,这样我希望在实时站点 ( proxy ) 上看到更新。但有时,大约 20-30% 的时间这不会反映在代理上,即使我看到 CDN 已正确更新。我无法理解为什么。

我已关闭代理上的缓存。 多次清除缓存最终会在清除后代理不显示正确内容显示正确内容

对以下不同阶段的回应。

CDN 来自 Microsoft azure by Verizon

源头:

Origin response header

CDN 标头:

enter image description here

实时标题

Live response headers

代理配置:

server {
    server_name <DOMAIN>;
    location / {
      proxy_no_cache 1;
      proxy_cache_bypass 1; 
      proxy_redirect off;
      
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Real-IP       $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_headers_hash_max_size 512;
      proxy_headers_hash_bucket_size 128;
      
      proxy_hide_header Cache-Control;
      add_header Cache-Control max-age=120; #browser cache of 120s
      proxy_pass "https://<CDN-BASE-URL>$request_uri";
    }
}

仔细观察,Last-Modified 似乎不匹配,这可能是原因吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)