feat(cache): set max-age for public accessible static resources

This commit is contained in:
HFO4
2022-12-14 15:28:19 +08:00
parent 8c5ba89f7d
commit 50a3917a65
5 changed files with 38 additions and 6 deletions

View File

@@ -85,3 +85,21 @@ func TestCacheControl(t *testing.T) {
TestFunc(c)
a.Contains(c.Writer.Header().Get("Cache-Control"), "no-cache")
}
func TestSandbox(t *testing.T) {
a := assert.New(t)
TestFunc := Sandbox()
rec := httptest.NewRecorder()
c, _ := gin.CreateTestContext(rec)
TestFunc(c)
a.Contains(c.Writer.Header().Get("Content-Security-Policy"), "sandbox")
}
func TestStaticResourceCache(t *testing.T) {
a := assert.New(t)
TestFunc := StaticResourceCache()
rec := httptest.NewRecorder()
c, _ := gin.CreateTestContext(rec)
TestFunc(c)
a.Contains(c.Writer.Header().Get("Cache-Control"), "public, max-age")
}