Skip to content

Commit

Permalink
Fix: Return immutable Cache-Control headers for UnixFS directories
Browse files Browse the repository at this point in the history
  • Loading branch information
acejam committed Jul 25, 2024
1 parent 2816b71 commit d7ab475
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following emojis are used to highlight certain changes:

- `bitswap/server` minor memory use and performance improvements
- `bitswap` unify logger names to use uniform format bitswap/path/pkgname
- `gateway` now returns immutable cache-control headers for unixfs directories

### Removed

Expand Down
6 changes: 2 additions & 4 deletions gateway/handler_unixfs_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ func (i *handler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *
dirEtag := getDirListingEtag(resolvedPath.RootCid())
w.Header().Set("Etag", dirEtag)

// Add TTL if known.
if rq.ttl > 0 {
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(rq.ttl.Seconds())))
}
// Set Cache-Control
w.Header().Set("Cache-Control", immutableCacheControl)

if r.Method == http.MethodHead {
rq.logger.Debug("return as request's HTTP method is HEAD")
Expand Down

0 comments on commit d7ab475

Please sign in to comment.