-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
Bug Description
Use cache middleware to cache home page "/".
Use CacheInvalidator to skip cache, got error: runtime error: index out of range [0] with length 0.
How to Reproduce
1.use cache middleware to cache home page "/".
2.do not visit "/" in browser, so there will not be any cache of it.
3.visit "/login" page to login, then CacheInvalidator would return true now.
4.visit "/".
5.got error.
Expected Behavior
When restart the program, not every page is cached, when user logged in visit no cache page, it should be open normal.
Fiber Version
v3.0.0-beta.3
Code Snippet (optional)
var WebCache_Home = cache.New(cache.Config{
CacheInvalidator: auth.ValidateLogin,
Expiration: 10 * time.Minute,
KeyGenerator: func(c fiber.Ctx) string {
cacheKey := "homeLogout"
if auth.ValidateLogin(c){
cacheKey = "homeLogin"
}
return cacheKey
},
StoreResponseHeaders: true,
MaxBytes: 1 * 1024 * 1024,
})
app.Use("/:p<maxLen(0)>?", cache.WebCache_Home)
app.Get("/:p<maxLen(0)>?", user.HomeHandler)Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.
Reactions are currently unavailable