Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [ct_hammer] support HTTPS and Bearer token for Authentication.
* [preloader] support Bearer token Authentication for non temporal logs.
* [preloader] support end indexes
* [CTFE] Short cache max-age when get-entries returns fewer entries than requested by @robstradling in https://github.com/google/certificate-transparency-go/pull/1707

### CTFE Storage Saving: Extra Data Issuance Chain Deduplication

Expand Down
8 changes: 7 additions & 1 deletion trillian/ctfe/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const (
cacheControlHeader = "Cache-Control"
// Value for Cache-Control header when response contains immutable data, i.e. entries or proofs. Allows the response to be cached for 1 day.
cacheControlImmutable = "public, max-age=86400"
// Value for Cache-Control header when response contains immutable but partial data, i.e. fewer entries than requested. Allows the response to be cached for 1 minute.
cacheControlPartial = "public, max-age=60"
// HTTP content type header
contentTypeHeader string = "Content-Type"
// MIME content type for JSON
Expand Down Expand Up @@ -802,7 +804,11 @@ func getEntries(ctx context.Context, li *logInfo, w http.ResponseWriter, r *http
return http.StatusInternalServerError, fmt.Errorf("failed to process leaves returned from backend: %s", err)
}

w.Header().Set(cacheControlHeader, cacheControlImmutable)
if len(rsp.Leaves) < int(count) {
w.Header().Set(cacheControlHeader, cacheControlPartial)
} else {
w.Header().Set(cacheControlHeader, cacheControlImmutable)
}
w.Header().Set(contentTypeHeader, contentTypeJSON)
jsonData, err := json.Marshal(&jsonRsp)
if err != nil {
Expand Down
Loading