aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Scott Leggett <scott@sl.id.au> 2024-10-03 19:51:28 +0800
committerGravatar Frédéric Guillot <f@miniflux.net> 2024-10-04 17:47:48 -0700
commit562a7b79a57bc9f3b25225486084fcb9da84b7d2 (patch)
treed280b4eb607aa756e6fddea608f423cbde3c165e
parentcb610230d9dd141201ad09cae3d1dd0f6274de29 (diff)
downloadv2-562a7b79a57bc9f3b25225486084fcb9da84b7d2.tar.gz
v2-562a7b79a57bc9f3b25225486084fcb9da84b7d2.tar.zst
v2-562a7b79a57bc9f3b25225486084fcb9da84b7d2.zip
fix: update Last-Modified if it changes in a 304 response
When a server returns a 304 response with a strong validator, any other stored fields must be updated if they are also present in the response. This behaviour is described in RFC9111, sections 3.2 and 4.3.4.
-rw-r--r--internal/reader/handler/handler.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/reader/handler/handler.go b/internal/reader/handler/handler.go
index 3a588b04..04275598 100644
--- a/internal/reader/handler/handler.go
+++ b/internal/reader/handler/handler.go
@@ -326,8 +326,6 @@ func RefreshFeed(store *storage.Storage, userID, feedID int64, forceRefresh bool
go integration.PushEntries(originalFeed, newEntries, userIntegrations)
}
- // We update caching headers only if the feed has been modified,
- // because some websites don't return the same headers when replying with a 304.
originalFeed.EtagHeader = responseHandler.ETag()
originalFeed.LastModifiedHeader = responseHandler.LastModified()
@@ -343,6 +341,11 @@ func RefreshFeed(store *storage.Storage, userID, feedID int64, forceRefresh bool
slog.Int64("user_id", userID),
slog.Int64("feed_id", feedID),
)
+ // Last-Modified may be updated even if ETag is not. In this case, per
+ // RFC9111 sections 3.2 and 4.3.4, the stored response must be updated.
+ if responseHandler.LastModified() != "" {
+ originalFeed.LastModifiedHeader = responseHandler.LastModified()
+ }
}
originalFeed.ResetErrorCounter()