Test_CacheMinFreshForcesRevalidation() — fiber Function Reference
Architecture documentation for the Test_CacheMinFreshForcesRevalidation() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 7f5ed305_70c9_d2b2_1910_2af251025fde["Test_CacheMinFreshForcesRevalidation()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 7f5ed305_70c9_d2b2_1910_2af251025fde -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style 7f5ed305_70c9_d2b2_1910_2af251025fde fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2514–2549
func Test_CacheMinFreshForcesRevalidation(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New())
var count int
app.Get("/", func(c fiber.Ctx) error {
count++
c.Set(fiber.HeaderCacheControl, "public, max-age=5")
return c.SendString(strconv.Itoa(count))
})
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "1", string(body))
req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
req.Header.Set(fiber.HeaderCacheControl, "min-fresh=10")
resp, err = app.Test(req)
require.NoError(t, err)
require.Equalf(t, cacheMiss, resp.Header.Get("X-Cache"), "dirs=%+v Age=%s count=%d", parseRequestCacheControlString("min-fresh=10"), resp.Header.Get(fiber.HeaderAge), count)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "2", string(body))
resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheHit, resp.Header.Get("X-Cache"))
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "2", string(body))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CacheMinFreshForcesRevalidation() do?
Test_CacheMinFreshForcesRevalidation() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheMinFreshForcesRevalidation() defined?
Test_CacheMinFreshForcesRevalidation() is defined in middleware/cache/cache_test.go at line 2514.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free