咱們來看看每一個header的具體含義。 html
Request 瀏覽器
Cache-Control: max-age=0 | 以秒爲單位 |
If-Modified-Since: Mon, 19 Nov 2012 08:38:01 GMT | 緩存文件的最後修改時間。 |
If-None-Match: "0693f67a67cc1:0" | 緩存文件的Etag值 |
Cache-Control: no-cache | 不使用緩存 |
Pragma: no-cache | 不使用緩存 |
Response 緩存
Cache-Control: public | 響應被緩存,而且在多用戶間共享, (公有緩存和私有緩存的區別,請看另外一節) |
Cache-Control: private | 響應只能做爲私有緩存,不能在用戶之間共享 |
Cache-Control:no-cache | 提醒瀏覽器要從服務器提取文檔進行驗證 |
Cache-Control:no-store | 絕對禁止緩存(用於機密,敏感文件) |
Cache-Control: max-age=60 | 60秒以後緩存過時(相對時間) |
Date: Mon, 19 Nov 2012 08:39:00 GMT | 當前response發送的時間 |
Expires: Mon, 19 Nov 2012 08:40:01 GMT | 緩存過時的時間(絕對時間) |
Last-Modified: Mon, 19 Nov 2012 08:38:01 GMT | 服務器端文件的最後修改時間 |
ETag: "20b1add7ec1cd1:0" | 服務器端文件的Etag值 |
若是同時存在cache-control和Expires怎麼辦呢?
瀏覽器老是優先使用cache-control,若是沒有cache-control才考慮Expires 服務器