Skip to content

Commit

Permalink
Shortened cache-lenght for ETags
Browse files Browse the repository at this point in the history
  • Loading branch information
Blockitifluy committed Jun 4, 2024
1 parent 4ea87cc commit 37179fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/gorilla/mux"
)

const assetCacheControl string = "must-revalidate, max-age=604800" // Caches for one week
const assetCacheControl string = "must-revalidate, max-age=86400" // Caches for one day

var openedCache = map[string]*AssetCache{}

Expand Down
7 changes: 7 additions & 0 deletions api/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ func (srv *Server) APIGetCommentsFromPost(w http.ResponseWriter, r *http.Request
}

zipped, err := utility.GZipBytes(json)
if err != nil {
utility.Error(w, utility.HTTPError{
Public: utility.PublicServerError,
Message: err.Error(),
Code: 500,
})
}

w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Encoding", "gzip")
Expand Down
4 changes: 2 additions & 2 deletions utility/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
// ImageSizeLimit is the size limit of all uploaded images
const ImageSizeLimit = 5000 * 1000

// ImageMaxAge is the cache length
const ImageMaxAge = 14 * 7 * 24 * int(time.Hour)
// ImageMaxAge is the cache length (a week)
const ImageMaxAge = 2 * 7 * 24 * int(time.Hour)

const maxSize = 800

Expand Down

0 comments on commit 37179fd

Please sign in to comment.