Skip to content

Commit 7fb2721

Browse files
committed
send 304 to the user if file not change
1 parent a0b01f9 commit 7fb2721

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

internal/http/routes/bookmark.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,19 @@ func (r *BookmarkRoutes) bookmarkThumbnailHandler(c *gin.Context) {
165165
return
166166
}
167167

168+
etag := "w/" + model.GetThumbnailPath(bookmark) + "-" + bookmark.ModifiedAt
169+
170+
// Check if the client's ETag matches the current ETag
171+
if c.GetHeader("If-None-Match") == etag {
172+
c.Status(http.StatusNotModified)
173+
return
174+
}
175+
168176
options := &response.SendFileOptions{
169177
Headers: []http.Header{
178+
{"Cache-Control": {"no-cache , must-revalidate"}},
170179
{"Last-Modified": {bookmark.ModifiedAt}},
171-
{"ETag": {"w/" + model.GetThumbnailPath(bookmark) + "-" + bookmark.ModifiedAt}},
180+
{"ETag": {etag}},
172181
},
173182
}
174183

0 commit comments

Comments
 (0)