From 7640a8cbab897b6791e885534ec9650dee669ce2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= <fred@miniflux.net>
Date: Mon, 9 Apr 2018 20:18:54 -0700
Subject: [PATCH] Ignore caching headers for feeds that send "Expires: 0"

---
 http/client.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/http/client.go b/http/client.go
index 9bcd14ed..1884224c 100644
--- a/http/client.go
+++ b/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
 }
 
-- 
GitLab