上海外滩夜景,静态资源,适合观察 CDN 命中

阿里云源站 · 上海 ECS

CDN / ESA 观测台

同一台机器同时提供可缓存静态和必须回源的动态 API。先直连源站看基线,再把域名接到 CDN 或 ESA,对比响应头。

源站 origin.domain-4-testing.com · 本页 lab.domain-4-testing.com

动态 · 服务器时间

GET /api/time · Cache-Control: no-store

加载中…

        
      

动态 · 用户信息

GET /api/me · Cookie 会话 · private, no-store

加载中…

        
      

可缓存 JSON

GET /api/cache · public, max-age=30

加载中…

        
      

动态 · 源站看到的请求

GET /api/echo · 看 Host / X-Forwarded-For / CDN 头

加载中…

        
      

怎么测

  1. 直连源站:curl -sI http://origin.domain-4-testing.com/static/shanghai.jpg,应看到 X-Origin-Request-Id,没有 CDN 命中头。
  2. 静态图和 /static/blob.bin(256KB)适合观察缓存 HIT / Age。
  3. /api/time 和 /api/me 接加速后仍应回源:每次 X-Origin-Request-Id 会变。
  4. /api/cache 接 CDN 后 30 秒内应变 HIT,X-Origin-Request-Id 不变。
  5. 接 ESA 时把 origin.domain-4-testing.com 当源站,把 lab.domain-4-testing.com 做 CNAME。