[nginx] X-Cache: HIT的意思

本文分享了一次因缓存设置不当导致接口返回数据异常的经历。作者通过观察X-Cache:HIT状态码发现接口返回的数据来自缓存而非实时数据源,从而揭示了问题所在。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

请求返回的数据是从缓存里拿到的X-Cache: HIT

缓存命中了

遇到一个返回接口数据总是不对,在看到X-Cache: HIT才发现

给接口设置了缓存!!!

按照上面定义,请帮我标注出来[root@keepmoving ~]# curl -v -H "Origin: http://example.com" -X GET "https://www.keepmoving123.cn/test/test123.html" Note: Unnecessary use of -X or --request, GET is already inferred. * Trying 203.193.226.100:443... * Connected to www.keepmoving123.cn (203.193.226.100) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt * CApath: none * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=keepmoving123.cn * start date: Feb 8 00:00:00 2025 GMT * expire date: May 8 23:59:59 2025 GMT * subjectAltName: host "www.keepmoving123.cn" matched cert's "www.keepmoving123.cn" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G2 * SSL certificate verify ok. * Using HTTP2, server supports multiplexing * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x55b69735fd90) > GET /test/test123.html HTTP/2 > Host: www.keepmoving123.cn > user-agent: curl/7.79.1 > accept: */* > origin: http://example.com > * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * old SSL session ID is stale, removing * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! < HTTP/2 200 < date: Thu, 13 Mar 2025 09:34:15 GMT < content-type: text/html < content-length: 370 < server: openresty < last-modified: Thu, 06 Mar 2025 13:37:33 GMT < etag: "67c9a51d-172" < x-ccdn-expires: 2591893 < via: CHN-GZguiyang-AREACT1-CACHE58[29],CHN-GZguiyang-AREACT1-CACHE19[0,TCP_HIT,20],CHN-HNchangsha-GLOBAL1-CACHE34[43],CHN-HNchangsha-GLOBAL1-CACHE19[0,TCP_HIT,36] < x-hcs-proxy-type: 1 < x-ccdn-cachettl: 2592000 < x-ccdn-req-id-46b1: e47b7ecf9522344085fd872944737d22 < nginx-hit: 1 < age: 107 < accept-ranges: bytes < access-control-expose-headers: Content-Length,Content-Encoding < access-control-allow-origin: http://*.exampel.com < access-control-allow-methods: GET,POST,HEAD,OPTIONS < content-disposition: attachment;filename=test150x150.jpg < access-control-allow-headers: X- Custom-Header,Origin, X-Requested-With, Content-Type, Accept, Authorization < strict-transport-security: max-age=36000 < <!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>keepmoving test</title> </head> <body> <h1>KeepMoving</h1> <h2>CDN启蒙实践</h2> <h2>卜永进 test</h2> <h2>buyongjin test</h2> <h2>buyongjin test</h2> <h2>buyongjin test</h2> </body> </html> * Connection #0 to host www.keepmoving123.cn left intact
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值