Skip to content

Commit

Permalink
refactor: make Cache-Control on generated html optional
Browse files Browse the repository at this point in the history
This allows us to ship this as backward-compatible fix
  • Loading branch information
lidel committed Jul 29, 2024
1 parent 9cd2679 commit bca4a26
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tests/path_gateway_unixfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ func TestGatewayCache(t *testing.T) {
tests := SugarTests{
{
Name: "GET for /ipfs/ unixfs dir listing succeeds",
Hint: "UnixFS directory listings are generated HTML, which may change over time, and can't be cached forever. Still, should have a meaningful cache-control header.",
Request: Request().
Path("/ipfs/{{CID}}/root2/root3/", fixture.MustGetCid()),
Response: Expect().
Status(200).
Headers(
Header("Cache-Control").
Equals("public, max-age=604800, stale-while-revalidate=2678400"),
Header("X-Ipfs-Path").
Equals("/ipfs/{{CID}}/root2/root3/", fixture.MustGetCid()),
Header("X-Ipfs-Roots").
Equals("{{CID1}},{{CID2}},{{CID3}}", fixture.MustGetCid(), fixture.MustGetCid("root2"), fixture.MustGetCid("root2", "root3")),
Header("Etag").
Matches("DirIndex-.*_CID-{{cid}}", fixture.MustGetCid("root2", "root3")),
Response: AllOf(
Expect().
Status(200).
Headers(
Header("X-Ipfs-Path").
Equals("/ipfs/{{CID}}/root2/root3/", fixture.MustGetCid()),
Header("X-Ipfs-Roots").
Equals("{{CID1}},{{CID2}},{{CID3}}", fixture.MustGetCid(), fixture.MustGetCid("root2"), fixture.MustGetCid("root2", "root3")),
Header("Etag").
Matches("DirIndex-.*_CID-{{cid}}", fixture.MustGetCid("root2", "root3")),
),
AnyOf(
Expect().Headers(Header("Cache-Control").IsEmpty()),
Expect().Headers(Header("Cache-Control").Equals("public, max-age=604800, stale-while-revalidate=2678400")),
),
),
},
{
Name: "GET for /ipfs/ unixfs dir with index.html succeeds",
Expand Down

0 comments on commit bca4a26

Please sign in to comment.