"
ASP.NET (snapshot 2017) Microsoft documentation and samples

Response compression sample application (ASP.NET Core 2.x)

This sample illustrates the use of ASP.NET Core 2.x Response Compression Middleware to compress HTTP responses for. The sample demonstrates Gzip and custom compression providers for text and image responses and shows how to add a MIME type for compression. For the ASP.NET Core 1.x sample, see Response compression sample application (ASP.NET Core 1.x).

Examples in this sample

When the request includes the Accept-Encoding header and response compression is successful, the middleware automatically adds a Vary: Accept-Encoding header to the response. The Vary header instructs caches to maintain multiple copies of the response based on alternative values of Accept-Encoding, so both a compressed (gzip) and uncompressed version are stored in caches for systems that can either accept the compressed or the uncompressed response.

Using the sample

  1. Make a request using Fiddler, Firebug, or Postman to the application without an Accept-Encoding header and note the response payload, response size, and response headers.
  2. Add an Accept-Encoding: gzip header and note the compressed response size and response headers. The response size drops, and the Content-Encoding: gzip response header is included by the middleware. When you look at the response body for the Lorem Ipsum or testfile1kb.txt response, you see that the text is compressed and unreadable.
  3. Add an Accept-Encoding: mycustomcompression header and note the response headers. The CustomCompressionProvider is an empty implementation that doesn’t actually compress the response, but you can create a custom compression stream wrapper for the CreateStream() method.




Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17
Link to this page: http://www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/performance/response-compression/samples/2.x/README.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <MAIL ME>  <ABOUT ME>  < THANKS ME>