Varnish 是一款高性能且開源的反向代理服務器和 HTTP 加速器,其採用全新的軟件體系機構,和如今的硬件體系緊密配合,與傳統的 squid 相比,varnish 具備性能更高、速度更快、管理更加方便等諸多優勢,不少大型的網站都開始嘗試使用 varnish 來替換 squid,這些都促進 varnish 迅速發展起來。緩存
挪威的最大的在線報紙 Verdens Gang(vg.no) 使用 3 臺 Varnish 代替了原來的 12 臺 Squid,性能比之前更好,這是 Varnish 最成功的應用案例。服務器
程序的運行具備局部性特徵:ide
時間局部性:一個剛訪問過的數據,隨後在很短的時間內可能再次被訪問到性能
空間局部性:一個數據被訪問到,其周邊的數據也可能被訪問到網站
cache:命中 ui
熱區:局部性;spa
時效性:代理
緩存空間耗盡:LRUorm
過時:緩存清理it
緩存命中率:hit/(hit+miss)
(0,1)
頁面命中率:基於頁面數量進行衡量
字節命中率:基於頁面的體積進行衡量
緩存與否:
私有數據:private,private cache;
公共數據:public, public or private cache;
Cache-related Headers Fields
The most important caching header fields are:
Expires:過時時間;
Expires:Thu, 22 Oct 2026 06:34:30 GMT
Cache-Control
Etag
Last-Modified
If-Modified-Since
If-None-Match
Vary
Age
緩存有效性判斷機制:
過時時間:Expires
HTTP/1.0
Expires
HTTP/1.1
Cache-Control: maxage=
Cache-Control: s-maxage=
條件式請求:
Last-Modified/If-Modified-Since
Etag/If-None-Match
Expires:Thu, 13 Aug 2026 02:05:12 GMT
Cache-Control:max-age=315360000
ETag:"1ec5-502264e2ae4c0"
Last-Modified:Wed, 03 Sep 2014 10:00:27 GMT
cache-request-directive =
"no-cache"
| "no-store"
| "max-age" "=" delta-seconds
| "max-stale" [ "=" delta-seconds ]
| "min-fresh" "=" delta-seconds
| "no-transform"
| "only-if-cached"
| cache-extension
cache-response-directive =
"public"
| "private" [ "=" <"> 1#field-name <"> ]
| "no-cache" [ "=" <"> 1#field-name <"> ]
| "no-store"
| "no-transform"
| "must-revalidate"
| "proxy-revalidate"
| "max-age" "=" delta-seconds
| "s-maxage" "=" delta-seconds
| cache-extension
開源解決方案:
squid:
varnish:
varnish官方站點: http://www.varnish-cache.org/
Community
Enterprise
This is Varnish Cache, a high-performance HTTP accelerator.