The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::Gzip - Plugin to Gzip Mojolicious responses

STATUS

SYNOPSIS

  # Mojolicious::Lite
  plugin 'Gzip';

  # With minimum size in bytes required before gzipping. Default is 860.
  plugin Gzip => {min_size => 1500};

  # Mojolicious
  $app->plugin('Gzip');

  # With minimum size in bytes required before gzipping. Default is 860.
  $app->plugin(Gzip => {min_size => 1500});

WARNING

This module can be inefficient for large static files. It loads the entire file into memory and then gzips it, resulting in both the original file and the gzipped one in memory at once. By default, Mojolicious serves static files from disk, which is much more memory efficient. For static files, you may want to compress them ahead of time and use something like Mojolicious::Static::Role::Compressed to serve them, or a service like Cloudlfare, which will compress files for you. For gzipping dynamic content, you should consider using "compress" in Mojolicious::Renderer instead.

DESCRIPTION

Mojolicious::Plugin::Gzip gzips all responses equal to or greater than a "min_size" by using the "after_dispatch" in Mojolicious hook. Mojolicious::Plugin::Gzip will only gzip a response if all of these conditions are met:

Mojolicious::Plugin::Gzip will do these things if those conditions are met:

OPTIONS

min_size

  # Mojolicious::Lite
  plugin 'Gzip' => {min_size => 1500};

  # Mojolicious
  $app->plugin(Gzip => {min_size => 1500});

Sets the minimum "body_size" in Mojo::Content required before response content will be gzipped. If the "body_size" in Mojo::Content is greater than or equal to "min_size", then it will be gzipped. Default is 860.

AUTHOR

Adam Hopkins <srchulo@cpan.org>

COPYRIGHT

Copyright 2019- Adam Hopkins

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO