From 9cd2679655beaab07ebb6225cb065c7adc10b6f0 Mon Sep 17 00:00:00 2001 From: Joshua Noble Date: Fri, 26 Jul 2024 17:29:21 -0400 Subject: [PATCH 1/3] fix: Verify Cache-Control header for UnixFS directories --- tests/path_gateway_unixfs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/path_gateway_unixfs_test.go b/tests/path_gateway_unixfs_test.go index 0dcc0218a..912f87a62 100644 --- a/tests/path_gateway_unixfs_test.go +++ b/tests/path_gateway_unixfs_test.go @@ -90,7 +90,7 @@ func TestGatewayCache(t *testing.T) { Status(200). Headers( Header("Cache-Control"). - IsEmpty(), + Equals("public, max-age=604800, stale-while-revalidate=2678400"), Header("X-Ipfs-Path"). Equals("/ipfs/{{CID}}/root2/root3/", fixture.MustGetCid()), Header("X-Ipfs-Roots"). From bca4a265d956d3d85978c8405eef57613c8c5e17 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 29 Jul 2024 20:23:32 +0200 Subject: [PATCH 2/3] refactor: make Cache-Control on generated html optional This allows us to ship this as backward-compatible fix --- tests/path_gateway_unixfs_test.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/path_gateway_unixfs_test.go b/tests/path_gateway_unixfs_test.go index 912f87a62..c2cb55ce4 100644 --- a/tests/path_gateway_unixfs_test.go +++ b/tests/path_gateway_unixfs_test.go @@ -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", From a4818e56326ae2571ae09cb40b389ab52a2654eb Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 29 Jul 2024 21:50:26 +0200 Subject: [PATCH 3/3] docs: v0.6.1 changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1c28f1b..bcdeb3d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.1] - 2024-07-29 +### Changed +- Support meaningful `Cache-Control` on generated UnixFS directory listing responses on `/ipfs` namespace + ## [0.6.0] - 2024-06-10 ### Changed - Gateway URL