Skip to content
Easily adds gzip compression to your Nancy web application.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
src Fix nuspec file path Aug 3, 2017
tools Initial source Feb 20, 2016
.gitignore exclude .vs folder from repo Jun 23, 2017
LICENSE Initial commit Feb 20, 2016
README.md

README.md

Nancy.Gzip Build status License

Adds gzip compression to your Nancy web application.

Installation

PM> Install-Package Nancy.Gzip

General Usage

Enable gzip compression in your bootstrapper.

public class Bootstrapper : DefaultNancyBootstrapper
{
    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
        // Enable Compression with Default Settings
        pipelines.EnableGzipCompression();

        base.ApplicationStartup(container, pipelines);
    }
}

Settings

There are only two setings in which you can configure

Minimum Bytes

The default minimum size (Content-Length) of output before it will be compressed is 4096. If the size is below this amount, it will not be compressed.

Mime Types

There are default mime types which specify which mime types are valid for compression. You can add your own content types to this list.

The defaults are:

  • text/plain
  • text/html
  • text/xml
  • text/css
  • application/json
  • application/x-javascript
  • application/atom+xml

Settings Example

public class Bootstrapper : DefaultNancyBootstrapper
{
    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
        // Enable Compression with Settings
        var settings = new GzipCompressionSettings();
        settings.MinimumBytes = 1024;
        settings.MimeTypes.Add("application/vnd.myexample");
        pipelines.EnableGzipCompression(settings);

        base.ApplicationStartup(container, pipelines);
    }
}

Icon

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

You can’t perform that action at this time.