File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -624,7 +624,7 @@ func (c *DefaultCtx) Fresh() bool {
624
624
if err != nil {
625
625
return false
626
626
}
627
- return lastModifiedTime .Before (modifiedSinceTime )
627
+ return lastModifiedTime .Compare (modifiedSinceTime ) != 1
628
628
}
629
629
}
630
630
}
Original file line number Diff line number Diff line change @@ -1397,6 +1397,10 @@ func Test_Ctx_Fresh(t *testing.T) {
1397
1397
require .False (t , c .Fresh ())
1398
1398
1399
1399
c .Request ().Header .Set (HeaderIfModifiedSince , "Wed, 21 Oct 2015 07:28:00 GMT" )
1400
+ require .True (t , c .Fresh ())
1401
+
1402
+ c .Request ().Header .Set (HeaderIfModifiedSince , "Wed, 21 Oct 2015 07:27:59 GMT" )
1403
+ c .Response ().Header .Set (HeaderLastModified , "Wed, 21 Oct 2015 07:28:00 GMT" )
1400
1404
require .False (t , c .Fresh ())
1401
1405
}
1402
1406
@@ -1412,6 +1416,18 @@ func Benchmark_Ctx_Fresh_WithNoCache(b *testing.B) {
1412
1416
}
1413
1417
}
1414
1418
1419
+ // go test -v -run=^$ -bench=Benchmark_Ctx_Fresh_LastModified -benchmem -count=4
1420
+ func Benchmark_Ctx_Fresh_LastModified (b * testing.B ) {
1421
+ app := New ()
1422
+ c := app .AcquireCtx (& fasthttp.RequestCtx {})
1423
+
1424
+ c .Response ().Header .Set (HeaderLastModified , "Wed, 21 Oct 2015 07:28:00 GMT" )
1425
+ c .Request ().Header .Set (HeaderIfModifiedSince , "Wed, 21 Oct 2015 07:28:00 GMT" )
1426
+ for n := 0 ; n < b .N ; n ++ {
1427
+ c .Fresh ()
1428
+ }
1429
+ }
1430
+
1415
1431
// go test -run Test_Ctx_Binders -v
1416
1432
func Test_Ctx_Binders (t * testing.T ) {
1417
1433
t .Parallel ()
You can’t perform that action at this time.
0 commit comments