---
title: "X-Cache 和 X-Cache-Lookup "
author: "TimerBin"
date: "2015-10-27T16:38:08Z"
tags: []
categories: ["互联网"]
slug: "x-cache-x-cache-lookup"
draft: false
lastmod: "2015-10-27T16:38:08Z"
id: 2252491
url: "https://timerbin.iteye.com/blog/2252491"
---

在Http协议的Response Header中，可根据以下两项来判断是否被缓存命中。

```
X-Cache:HIT from www.cdn.com
X-Via:代理服务器地址信息
```

x-cache-lookup:指专门查看代理服务器中是否有某个网页缓存:有就返回HIT,没有返回MISS。

x-cache:项指浏览器从何处、是在哪个代理缓存载入的网页文件:服务器名后的3128指服务器端口。

注：X-Via 未查到相关资料说明

 

可通过对Response Header进行以下配置来进行设置，不被任何代理缓存命中，每次取最新信息

```
// Http 1.0 header
response.setDateHeader("Expires", 1L);
response.addHeader("Pragma", "no-cache");
// Http 1.1 header
response.setHeader("Cache-Control", "no-cache, no-store, max-age=0");
```