// stream the cache item back to the client
stream the cache item back to the client
// stream the cache item back to the client
func stream(w http.ResponseWriter, req *http.Request, item *CacheItem) {
	item.hits++
	w.Header().Set("Etag", fmt.Sprintf("W/\"%s\"", item.etag))
	w.Header().Set("Content-Type", item.contenttype)
	w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d, must-revalidate", cacheMaxAge))
	w.Header().Set("X-Cache-Hit", fmt.Sprintf("%d", item.hits))
	w.Header().Add("Vary", "Accept-Encoding")
	acceptedEncodings, _ := parseEncodings(req.Header.Get("Accept-Encoding"))
	if acceptedEncodings["gzip"] > 0.0 && len(item.gzipbuf) > 0 {
		w.Header().Set("Content-Length", fmt.Sprintf("%d", len(item.gzipbuf)))
		w.Header().Set("Content-Encoding", "gzip")
		w.Write(item.gzipbuf)
	} else {
		w.Header().Set("Content-Length", fmt.Sprintf("%d", item.Size()))
		w.Write(item.buffer)
	}
}
func stream ( w http . ResponseWriter , req * http . Request , item * CacheItem ) { item . hits ++ w . Header ( ) . Set ( " " , fmt . Sprintf ( " \" \" " , item . etag ) ) w . Header ( ) . Set ( " " , item . contenttype ) w . Header ( ) . Set ( " " , fmt . Sprintf ( " " , cacheMaxAge ) ) w . Header ( ) . Set ( " " , fmt . Sprintf ( " " , item . hits ) ) w . Header ( ) . Add ( " " , " " ) acceptedEncodings , _ := parseEncodings ( req . Header . Get ( " " ) ) if acceptedEncodings [ " " ] > 0.0 && len ( item . gzipbuf ) > 0 { w . Header ( ) . Set ( " " , fmt . Sprintf ( " " , len ( item . gzipbuf ) ) ) w . Header ( ) . Set ( " " , " " ) w . Write ( item . gzipbuf ) } else { w . Header ( ) . Set ( " " , fmt . Sprintf ( " " , item . Size ( ) ) ) w . Write ( item . buffer ) } }
stream the cache item back to the client
stream the cache item back to the client
// check to see if we can send compressed data