@@ -105,11 +105,13 @@ type Server struct {
105
105
reqFaultMiss expvar.Int // miss in remote (S3) cache
106
106
reqForward expvar.Int // request forwarded directly to upstream
107
107
rspSave expvar.Int // successful response saved in local cache
108
+ rspSaveMem expvar.Int // response saved in memory cache
108
109
rspSaveError expvar.Int // error saving to local cache
109
110
rspSaveBytes expvar.Int // bytes written to local cache
110
111
rspPush expvar.Int // successful response saved in S3
111
112
rspPushError expvar.Int // error saving to S3
112
113
rspPushBytes expvar.Int // bytes written to S3
114
+ rspNotCached expvar.Int // response not cached anywhere
113
115
}
114
116
115
117
func (s * Server ) init () {
@@ -132,11 +134,13 @@ func (s *Server) Metrics() *expvar.Map {
132
134
m .Set ("req_fault_miss" , & s .reqFaultMiss )
133
135
m .Set ("req_forward" , & s .reqForward )
134
136
m .Set ("rsp_save" , & s .rspSave )
137
+ m .Set ("rsp_save_memory" , & s .rspSaveMem )
135
138
m .Set ("rsp_save_error" , & s .rspSaveError )
136
139
m .Set ("rsp_save_bytes" , & s .rspSaveBytes )
137
140
m .Set ("rsp_push" , & s .rspPush )
138
141
m .Set ("rsp_push_error" , & s .rspPushError )
139
142
m .Set ("rsp_push_bytes" , & s .rspPushBytes )
143
+ m .Set ("rsp_not_cached" , & s .rspNotCached )
140
144
return m
141
145
}
142
146
@@ -197,6 +201,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
197
201
if ! isVolatile && ! s .canCacheResponse (rsp ) {
198
202
// A response we cannot cache at all.
199
203
setXCacheInfo (rsp .Header , "fetch, uncached" , "" )
204
+ s .rspNotCached .Add (1 )
200
205
return nil
201
206
}
202
207
@@ -212,6 +217,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
212
217
updateCache = func () {
213
218
body := buf .Bytes ()
214
219
s .cacheStoreMemory (hash , maxAge , rsp .Header , body )
220
+ s .rspSaveMem .Add (1 )
215
221
216
222
// N.B. Don't persist on disk or in S3.
217
223
}
0 commit comments