Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() — fiber Function Reference
Architecture documentation for the Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 9e476e50_42fd_1694_7458_eeada311044f["Test_CacheSMaxAgeOverridesMaxAgeWhenLonger()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 9e476e50_42fd_1694_7458_eeada311044f -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style 9e476e50_42fd_1694_7458_eeada311044f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 1857–1895
func Test_CacheSMaxAgeOverridesMaxAgeWhenLonger(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=1, s-maxage=2")
return c.SendString(strconv.Itoa(count))
})
for time.Now().Nanosecond() >= int(100*time.Millisecond) {
time.Sleep(10 * time.Millisecond)
}
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
time.Sleep(1200 * time.Millisecond)
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, "1", string(body))
time.Sleep(1700 * time.Millisecond)
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, "2", string(body))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() do?
Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() defined?
Test_CacheSMaxAgeOverridesMaxAgeWhenLonger() is defined in middleware/cache/cache_test.go at line 1857.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free