Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Gzips Ring responses for user agents which can handle it.

Clojars Project cljdoc badge CircleCI


Apply the Ring middleware function ring.middleware.gzip/wrap-gzip to your Ring handler, typically at the top level (i.e. as the last bit of middleware in a -> form).


Add [amalloy/ring-gzip-middleware "0.1.4"] to your Leiningen dependencies.

Compression of seq bodies

In JDK versions <=6, does not actually flush data compressed so far, which means that every gzip response must be complete before any bytes hit the wire. While of marginal importance when compressing static files and other resources that are consumed in an all-or-nothing manner (i.e. virtually everything that is sent in a Ring response), lazy sequences are impacted negatively by this. In particular, long-polling or server-sent event responses backed by lazy sequences, when gzipped under <=JDK6, must be fully consumed before the client receives any data at all.

So, this middleware does not gzip-compress Ring seq response bodies unless the JDK in use is 7+, in which case it takes advantage of the new flush-ability of GZIPOutputStream there.


Copyright (C) 2010 Michael Stephens and other contributors.

Distributed under an MIT-style license (see LICENSE for details).