Ejemplo n.º 1
0
func (s *Server) checkCache(r *http.Request, f *storage.File) (cont bool, status int) {
	// Check etag
	if s.conf.ETagSupport {
		if ifNoneMatch := r.Header.Get("If-None-Match"); ifNoneMatch != "" {
			if ifNoneMatch == f.ETag() {
				status = http.StatusNotModified
				return
			}
		}
	}
	// Check if modified
	if tm, err := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && f.Time.Before(tm.Add(1*time.Second)) {
		status = http.StatusNotModified
		return
	}
	cont = true
	status = http.StatusOK
	return
}