From 048b70523a1405f7571caa80fd2b961be9c0b908 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 25 Jun 2026 17:24:08 -0500 Subject: [PATCH] headers: set public on cache control --- headers.go | 2 +- headers_test.go | 2 +- middles/cache_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/headers.go b/headers.go index 6bbd3b9..cba94fe 100644 --- a/headers.go +++ b/headers.go @@ -48,7 +48,7 @@ func SetRobotsTag(w http.ResponseWriter, instruction RobotIndex) { func SetCacheControl(w http.ResponseWriter, ttl time.Duration) { f := ttl.Seconds() i := int(f) - s := "private, max-age=" + strconv.Itoa(i) + s := "public, max-age=" + strconv.Itoa(i) w.Header().Add("Cache-Control", s) } diff --git a/headers_test.go b/headers_test.go index 2d42fd0..348472f 100644 --- a/headers_test.go +++ b/headers_test.go @@ -15,7 +15,7 @@ func Test_SetCacheControl(t *testing.T) { w := httptest.NewRecorder() SetCacheControl(w, 4*time.Minute) - must.Eq(t, "private, max-age=240", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=240", w.Header().Get("Cache-Control")) } func Test_SetContentType(t *testing.T) { diff --git a/middles/cache_test.go b/middles/cache_test.go index 64e7c51..ac03817 100644 --- a/middles/cache_test.go +++ b/middles/cache_test.go @@ -30,7 +30,7 @@ func TestCache_ServeHTTP_local(t *testing.T) { must.Eq(t, 200, w.Code) must.True(t, run.Load()) - must.Eq(t, "private, max-age=5", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=5", w.Header().Get("Cache-Control")) } func TestCache_ServeHTTP_staging_css(t *testing.T) { @@ -53,7 +53,7 @@ func TestCache_ServeHTTP_staging_css(t *testing.T) { must.Eq(t, 200, w.Code) must.True(t, run.Load()) - must.Eq(t, "private, max-age=60", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=60", w.Header().Get("Cache-Control")) } func TestCache_ServeHTTP_staging_txt(t *testing.T) { @@ -76,7 +76,7 @@ func TestCache_ServeHTTP_staging_txt(t *testing.T) { must.Eq(t, 200, w.Code) must.True(t, run.Load()) - must.Eq(t, "private, max-age=3600", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=3600", w.Header().Get("Cache-Control")) } func TestCache_ServeHTTP_production_css(t *testing.T) { @@ -99,7 +99,7 @@ func TestCache_ServeHTTP_production_css(t *testing.T) { must.Eq(t, 200, w.Code) must.True(t, run.Load()) - must.Eq(t, "private, max-age=10800", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=10800", w.Header().Get("Cache-Control")) } func TestCache_ServeHTTP_production_txt(t *testing.T) { @@ -122,5 +122,5 @@ func TestCache_ServeHTTP_production_txt(t *testing.T) { must.Eq(t, 200, w.Code) must.True(t, run.Load()) - must.Eq(t, "private, max-age=86400", w.Header().Get("Cache-Control")) + must.Eq(t, "public, max-age=86400", w.Header().Get("Cache-Control")) }