Skip to content

Commit

Permalink
send 304 to the user if file not change
Browse files Browse the repository at this point in the history
  • Loading branch information
Monirzadeh committed Jul 2, 2024
1 parent a0b01f9 commit 7fb2721
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/http/routes/bookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,19 @@ func (r *BookmarkRoutes) bookmarkThumbnailHandler(c *gin.Context) {
return
}

etag := "w/" + model.GetThumbnailPath(bookmark) + "-" + bookmark.ModifiedAt

// Check if the client's ETag matches the current ETag
if c.GetHeader("If-None-Match") == etag {
c.Status(http.StatusNotModified)
return
}

options := &response.SendFileOptions{
Headers: []http.Header{
{"Cache-Control": {"no-cache , must-revalidate"}},
{"Last-Modified": {bookmark.ModifiedAt}},
{"ETag": {"w/" + model.GetThumbnailPath(bookmark) + "-" + bookmark.ModifiedAt}},
{"ETag": {etag}},
},
}

Expand Down

0 comments on commit 7fb2721

Please sign in to comment.