gzip package:wai-extra

Use gzip to compress the body of the response.
Automatic gzip compression of responses.
Decide which files to compress based on MIME type The ByteString is the value of the "Content-Type" response header and will default to False if the header is missing. E.g. if you'd only want to compress json data, you might define your own function as follows:
myCheckMime mime = mime == "application/json"
Gzip behavior for files Only applies to ResponseFile (responseFile) responses. So any streamed data will be compressed based solely on the response headers having the right "Content-Type" and "Content-Length". (which are checked with gzipCheckMime and gzipSizeThreshold, respectively)
Skip compression when the size of the response body is below this amount of bytes (default: 860.) Setting this option to less than 150 will actually increase the size of outgoing data if its original size is less than 150 bytes. This will only skip compression if the response includes a "Content-Length" header AND the length is less than this threshold.
Takes the ETag response header into consideration when caching files in the given folder. If there's no ETag header, this setting is equivalent to GzipCacheFolder. N.B. Make sure the gzip middleware is applied before any Middleware that will set the ETag header.
Compress files, caching the compressed version in the given directory.
Compress files. Note that this may counteract zero-copy response optimizations on some platforms.
Gzip behavior for files.
Do not compress file (ResponseFile) responses. Any ResponseBuilder or ResponseStream might still be compressed.
If we use compression then try to use the filename with ".gz" appended to it. If the file is missing then try next action.
Default settings for the gzip middleware.
  • Does not compress files.
  • Uses defaultCheckMime.
  • Compession threshold set to 860 bytes.