Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update last modified timestamp without content update #2866

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/reader/fetcher/response_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestIsModified(t *testing.T) {
ETag: cachedEtag,
IsModified: false,
},
// This case is invalid per RFC9110 8.8.1, so ETag takes precedence.
// ETag takes precedence per RFC9110 8.8.1.
"Last-Modified changed only": {
Status: 200,
LastModified: "Thu, 22 Oct 2015 07:28:00 GMT",
Expand Down
7 changes: 5 additions & 2 deletions internal/reader/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
Expand Down
Loading