@@ -19,8 +19,8 @@ import (
1919)
2020
2121const (
22- CacheStatusHeader = "X-Httpcache-Status"
23- CacheStatusHeaderLegacy = "X-From-Cache" // Deprecated: use [CacheStatusHeader] instead
22+ CacheStatusHeader = "X-Httpcache-Status"
23+ FromCacheHeader = "X-From-Cache" // Deprecated: use [CacheStatusHeader] instead
2424)
2525
2626type CacheStatus struct {
@@ -37,14 +37,19 @@ type CacheStatus struct {
3737func (s CacheStatus ) ApplyTo (header http.Header ) {
3838 header .Set (CacheStatusHeader , s .Value )
3939 if s .Legacy != "" {
40- header .Set (CacheStatusHeaderLegacy , s .Legacy )
40+ header .Set (FromCacheHeader , s .Legacy )
4141 }
4242}
4343
44+ const (
45+ FromCache = "1"
46+ NotFromCache = ""
47+ )
48+
4449var (
45- CacheStatusHit = CacheStatus {"HIT" , "1" } // served from cache
46- CacheStatusMiss = CacheStatus {"MISS" , "" } // served from origin
47- CacheStatusStale = CacheStatus {"STALE" , "1" } // served from cache but stale
48- CacheStatusRevalidated = CacheStatus {"REVALIDATED" , "1" } // revalidated with origin server
49- CacheStatusBypass = CacheStatus {"BYPASS" , "" } // cache bypassed
50+ CacheStatusHit = CacheStatus {"HIT" , FromCache } // served from cache
51+ CacheStatusMiss = CacheStatus {"MISS" , NotFromCache } // served from origin
52+ CacheStatusStale = CacheStatus {"STALE" , FromCache } // served from cache but stale
53+ CacheStatusRevalidated = CacheStatus {"REVALIDATED" , FromCache } // revalidated with origin server
54+ CacheStatusBypass = CacheStatus {"BYPASS" , NotFromCache } // cache bypassed
5055)
0 commit comments