From bf1c8510930155a6f0e07de35149b360e61af3a6 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Tue, 2 Jul 2024 23:12:53 +0800 Subject: [PATCH] fetcher: use ETag as a stronger validator than Last-Modified As per the MDN article on HTTP caching: During cache revalidation, if both If-Modified-Since and If-None-Match are present, then If-None-Match takes precedence for the validator. https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching Previously Miniflux would consider a resource unmodified if the Last-Modified header had not changed, even if the ETag had changed. With this commit, Miniflux will consider a resource modified if the ETag header has changed, even if Last-Modified has not. This fixes Bug 1 in https://rachelbythebay.com/w/2024/06/11/fsr/ --- internal/reader/fetcher/response_handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/reader/fetcher/response_handler.go b/internal/reader/fetcher/response_handler.go index 1de3b384..540fdac0 100644 --- a/internal/reader/fetcher/response_handler.go +++ b/internal/reader/fetcher/response_handler.go @@ -56,12 +56,12 @@ func (r *ResponseHandler) IsModified(lastEtagValue, lastModifiedValue string) bo return false } - if r.ETag() != "" && r.ETag() == lastEtagValue { - return false + if r.ETag() != "" { + return r.ETag() != lastEtagValue } - if r.LastModified() != "" && r.LastModified() == lastModifiedValue { - return false + if r.LastModified() != "" { + return r.LastModified() != lastModifiedValue } return true