From 1bf9a49a799ec983da4c77f1a8b63afcd4aaa48a Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 29 Jul 2024 20:23:32 +0200 Subject: [PATCH] refactor: make Cache-Control on generated html optional This allows us to ship this as backward-compatible fix --- tests/path_gateway_unixfs_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/path_gateway_unixfs_test.go b/tests/path_gateway_unixfs_test.go index 912f87a62..9b0925084 100644 --- a/tests/path_gateway_unixfs_test.go +++ b/tests/path_gateway_unixfs_test.go @@ -84,13 +84,12 @@ 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"). @@ -98,6 +97,10 @@ func TestGatewayCache(t *testing.T) { 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",