Test_Cache_DateAndCacheControl() — fiber Function Reference
Architecture documentation for the Test_Cache_DateAndCacheControl() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD cb1d0ab3_8235_5230_b489_7193e4119f82["Test_Cache_DateAndCacheControl()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] cb1d0ab3_8235_5230_b489_7193e4119f82 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style cb1d0ab3_8235_5230_b489_7193e4119f82 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 4226–4286
func Test_Cache_DateAndCacheControl(t *testing.T) {
t.Parallel()
t.Run("date header parsing", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{Expiration: 1 * time.Hour}))
app.Get("/test", func(c fiber.Ctx) error {
c.Response().Header.Set("Date", "Mon, 02 Jan 2006 15:04:05 GMT")
c.Response().Header.Set("Cache-Control", "max-age=3600")
return c.SendString("test")
})
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, rsp.Header.Get("X-Cache"))
})
t.Run("invalid date header", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{Expiration: 1 * time.Hour}))
app.Get("/test", func(c fiber.Ctx) error {
c.Response().Header.Set("Date", "invalid")
c.Response().Header.Set("Cache-Control", "max-age=3600")
return c.SendString("test")
})
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, rsp.Header.Get("X-Cache"))
})
t.Run("cache control with quoted values", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{Expiration: 1 * time.Hour}))
app.Get("/test", func(c fiber.Ctx) error {
c.Response().Header.Set("Cache-Control", `max-age=3600, ext="value, with, commas"`)
return c.SendString("test")
})
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, rsp.Header.Get("X-Cache"))
})
t.Run("cache control with spaces", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{Expiration: 1 * time.Hour}))
app.Get("/test", func(c fiber.Ctx) error {
c.Response().Header.Set("Cache-Control", "max-age=3600 , public , must-revalidate")
return c.SendString("test")
})
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, rsp.Header.Get("X-Cache"))
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Cache_DateAndCacheControl() do?
Test_Cache_DateAndCacheControl() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_DateAndCacheControl() defined?
Test_Cache_DateAndCacheControl() is defined in middleware/cache/cache_test.go at line 4226.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free