Ring middleware for adding modern response compression to your web application. It supports Brotli, Deflate, GZip and ZStandard content encoding, and has sensible defaults for when to apply compression and when not avoid it (such as for image formats).
Note
Many reverse proxies and CDNs will automatically handle content encoding for you. However, you may want more control over how content encoding is handled, or you may not be using a reverse proxy at all.
Add the following dependency to your deps.edn file:
org.ring-clojure/ring-content-encoding {:mvn/version "0.1.0-SNAPSHOT"}
Or to your Leiningen project file:
[org.ring-clojure/ring-content-encoding "0.1.0-SNAPSHOT"]
Use the wrap-content-encoding function to add support for various
types of content encoding (i.e. compression).
(require '[ring.middleware.content-encoding :refer [wrap-content-encoding]])
(defn handler [_request]
{:status 200
:headers {"Content-Type" "text/plain; charset=utf-8"
"Content-Length" "55"}
:body "This text will be compressed if the client supports it."})
(def app
(wrap-content-encoding handler))Copyright © 2026 James Reeves
Released under the MIT license.