Browse Source

Ignore caching headers for feeds that send "Expires: 0"

Frédéric Guillot 8 years ago
parent
commit
7640a8cbab
1 changed files with 10 additions and 2 deletions
  1. 10 2
      http/client.go

+ 10 - 2
http/client.go

@@ -129,17 +129,25 @@ func (c *Client) executeRequest(request *http.Request) (*Response, error) {
 		ContentLength: resp.ContentLength,
 	}
 
-	logger.Debug("[HttpClient:%s] OriginalURL=%s, StatusCode=%d, ContentLength=%d, ContentType=%s, ETag=%s, LastModified=%s, EffectiveURL=%s",
+	logger.Debug("[HttpClient:%s] URL=%s, EffectiveURL=%s, Code=%d, Length=%d, Type=%s, ETag=%s, LastMod=%s, Expires=%s",
 		request.Method,
 		c.url,
+		response.EffectiveURL,
 		response.StatusCode,
 		resp.ContentLength,
 		response.ContentType,
 		response.ETag,
 		response.LastModified,
-		response.EffectiveURL,
+		resp.Header.Get("Expires"),
 	)
 
+	// Ignore caching headers for feeds that do not want any cache.
+	if resp.Header.Get("Expires") == "0" {
+		logger.Debug("[HttpClient] Ignore caching headers for %q", response.EffectiveURL)
+		response.ETag = ""
+		response.LastModified = ""
+	}
+
 	return response, err
 }