Skip to content

Commit fa7f9d7

Browse files
committed
end-user documentation of gzipping of Ring seq bodies under JDK6 vs. 7
1 parent 6c86e47 commit fa7f9d7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
## ring-gzip-middleware
22

3-
Gzips [Ring](http://github.com/mmcgrana/ring) responses for user agents which can handle it.
3+
Gzips [Ring](http://github.com/ring-clojure/ring) responses for user agents
4+
which can handle it.
45

56
### Usage
67

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

11-
1212
### Installation
1313

1414
Add `[amalloy/ring-gzip-middleware "0.1.2"]` to your Leingingen dependencies.
1515

16+
### Compression of seq bodies
17+
18+
In JDK versions <=6, [`java.util.zip.GZIPOutputStream.flush()` does not actually
19+
flush data compressed so
20+
far](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4813885), which means
21+
that every gzip response must be complete before any bytes hit the wire. While
22+
of marginal importance when compressing static files and other resources that
23+
are consumed in an all-or-nothing manner (i.e. virtually everything that is sent
24+
in a Ring response), lazy sequences are impacted negatively by this. In
25+
particular, long-polling or server-sent event responses backed by lazy
26+
sequences, when gzipped under <=JDK6, must be fully consumed before the client
27+
receives any data at all.
28+
29+
So, _this middleware does not gzip-compress Ring seq response bodies unless the
30+
JDK in use is 7+_, in which case it takes advantage of the new `flush`-ability
31+
of `GZIPOutputStream` there.
32+
1633
### License
1734

1835
Copyright (C) 2010 Michael Stephens and other contributors.

0 commit comments

Comments
 (0)