File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using GenHTTP . Api . Content ;
1+ using System . IO . Compression ;
2+ using GenHTTP . Api . Content ;
3+ using GenHTTP . Modules . Compression ;
24using GenHTTP . Modules . IO ;
35using GenHTTP . Modules . Layouting ;
46using GenHTTP . Modules . Layouting . Provider ;
7+ using GenHTTP . Modules . ServerCaching ;
58using GenHTTP . Modules . Webservices ;
69using GenHTTP . Modules . Websockets ;
710
@@ -34,7 +37,19 @@ private static LayoutBuilder AddStaticFiles(this LayoutBuilder app)
3437 {
3538 if ( Directory . Exists ( "/data/static" ) )
3639 {
37- app . Add ( "static" , Resources . From ( ResourceTree . FromDirectory ( "/data/static" ) ) ) ;
40+ var tree = ResourceTree . FromDirectory ( "/data/static" ) ;
41+
42+ var compression = CompressedContent . Default ( )
43+ . Level ( CompressionLevel . Optimal ) ;
44+
45+ var cache = ServerCache . TemporaryFiles ( )
46+ . Invalidate ( false ) ;
47+
48+ var handler = Resources . From ( tree ) // serve static resources
49+ . Add ( compression ) // compress them on-the-fly
50+ . Add ( cache ) ; // cache the compressed results
51+
52+ app . Add ( "static" , handler ) ;
3853 }
3954
4055 return app ;
Original file line number Diff line number Diff line change 88 </PropertyGroup >
99 <ItemGroup >
1010 <PackageReference Include =" GenHTTP.Core" Version =" 10.5.0" />
11- <PackageReference Include =" GenHTTP.Modules.Functional " Version =" 10.5.0" />
11+ <PackageReference Include =" GenHTTP.Modules.ServerCaching " Version =" 10.5.0" />
1212 <PackageReference Include =" GenHTTP.Modules.IO" Version =" 10.5.0" />
1313 <PackageReference Include =" GenHTTP.Modules.Layouting" Version =" 10.5.0" />
1414 <PackageReference Include =" GenHTTP.Modules.Webservices" Version =" 10.5.0" />
Original file line number Diff line number Diff line change 1010 "docker" : " 29.3.0" ,
1111 "docker_runtime" : " runc" ,
1212 "governor" : " performance" ,
13- "commit" : " b506385d " ,
13+ "commit" : " 8d1543bd " ,
1414 "tcp" : {
1515 "lo_mtu" : " 1500" ,
1616 "congestion" : " cubic" ,
Original file line number Diff line number Diff line change 350350 {
351351 "framework" : " genhttp" ,
352352 "language" : " C#" ,
353- "rps" : 179805 ,
354- "avg_latency" : " 6.70ms " ,
355- "p99_latency" : " 6.70ms " ,
356- "cpu" : " 6282.4 %" ,
357- "memory" : " 632MiB " ,
353+ "rps" : 159730 ,
354+ "avg_latency" : " 8.76ms " ,
355+ "p99_latency" : " 8.76ms " ,
356+ "cpu" : " 6193.5 %" ,
357+ "memory" : " 608MiB " ,
358358 "connections" : 1024 ,
359359 "threads" : 64 ,
360360 "duration" : " 5s" ,
361361 "pipeline" : 1 ,
362- "bandwidth" : " 10.67GB " ,
362+ "bandwidth" : " 9.46GB " ,
363363 "reconnects" : 0 ,
364- "status_2xx" : 916884 ,
364+ "status_2xx" : 814633 ,
365365 "status_3xx" : 0 ,
366366 "status_4xx" : 0 ,
367367 "status_5xx" : 0
Original file line number Diff line number Diff line change 350350 {
351351 "framework" : " genhttp" ,
352352 "language" : " C#" ,
353- "rps" : 175160 ,
354- "avg_latency" : " 31.77ms " ,
355- "p99_latency" : " 31.77ms " ,
356- "cpu" : " 6198.5 %" ,
357- "memory" : " 2.2GiB " ,
353+ "rps" : 174313 ,
354+ "avg_latency" : " 27.01ms " ,
355+ "p99_latency" : " 27.01ms " ,
356+ "cpu" : " 6284.4 %" ,
357+ "memory" : " 1.4GiB " ,
358358 "connections" : 4096 ,
359359 "threads" : 64 ,
360360 "duration" : " 5s" ,
361361 "pipeline" : 1 ,
362- "bandwidth" : " 10.39GB " ,
362+ "bandwidth" : " 10.25GB " ,
363363 "reconnects" : 0 ,
364- "status_2xx" : 893318 ,
364+ "status_2xx" : 889046 ,
365365 "status_3xx" : 0 ,
366366 "status_4xx" : 0 ,
367367 "status_5xx" : 0
Original file line number Diff line number Diff line change 350350 {
351351 "framework" : " genhttp" ,
352352 "language" : " C#" ,
353- "rps" : 164807 ,
354- "avg_latency" : " 40.90ms " ,
355- "p99_latency" : " 40.90ms " ,
356- "cpu" : " 6100.2 %" ,
357- "memory" : " 3 .8GiB" ,
353+ "rps" : 169210 ,
354+ "avg_latency" : " 40.68ms " ,
355+ "p99_latency" : " 40.68ms " ,
356+ "cpu" : " 6327.4 %" ,
357+ "memory" : " 1 .8GiB" ,
358358 "connections" : 6800 ,
359359 "threads" : 64 ,
360360 "duration" : " 5s" ,
361361 "pipeline" : 1 ,
362- "bandwidth" : " 9.78GB " ,
362+ "bandwidth" : " 9.92GB " ,
363363 "reconnects" : 0 ,
364- "status_2xx" : 840688 ,
364+ "status_2xx" : 863018 ,
365365 "status_3xx" : 0 ,
366366 "status_4xx" : 0 ,
367367 "status_5xx" : 0
You can’t perform that action at this time.
0 commit comments