Annotation of embedaddon/lighttpd/doc/outdated/compress.txt, revision 1.1.1.1
1.1 misho 1: ==================
2: Output Compression
3: ==================
4:
5: --------------------
6: Module: mod_compress
7: --------------------
8:
9:
10: .. meta::
11: :keywords: lighttpd, compress
12:
13: .. contents:: Table of Contents
14:
15: Description
16: ===========
17:
18: Output compression reduces the network load and can improve the overall
19: throughput of the webserver. All major http-clients support compression by
20: announcing it in the Accept-Encoding header. This is used to negotiate the
21: most suitable compression method. We support deflate, gzip and bzip2.
22:
23: deflate (RFC1950, RFC1951) and gzip (RFC1952) depend on zlib while bzip2
24: depends on libbzip2. bzip2 is only supported by lynx and some other console
25: text-browsers.
26:
27: We currently limit to compression support to static files.
28:
29: Caching
30: -------
31:
32: mod_compress can store compressed files on disk to optimize the compression
33: on a second request away. As soon as compress.cache-dir is set the files are
34: compressed.
35:
36: (You will need to create the cache directory if it doesn't already exist. The web server will not do this for you. The directory will also need the proper ownership. For Debian/Ubuntu the user and group ids should both be www-data.)
37:
38: The names of the cache files are made of the filename, the compression method
39: and the etag associated to the file.
40:
41: Cleaning the cache is left to the user. A cron job deleting files older than
42: 10 days could do it: ::
43:
44: find /var/www/cache -type f -mtime +10 | xargs -r rm
45:
46: Limitations
47: -----------
48:
49: The module limits the compression of files to files smaller than 128 MByte and
50: larger than 128 Byte.
51:
52: The lower limit is set as small files tend to become larger by compressing due
53: to the compression headers, the upper limit is set to work sensibly with
54: memory and cpu-time.
55:
56: Directories containing a tilde ('~') are not created automatically (See ticket
57: #113). To enable compression for user dirs you have to create the directories
58: by hand in the cache directory.
59:
60: Options
61: =======
62:
63: compress.allowed-encodings
64: override default set of allowed encodings
65:
66: e.g.: ::
67:
68: compress.allowed-encodings = ("bzip2", "gzip", "deflate")
69:
70: compress.cache-dir
71: name of the directory where compressed content will be cached
72:
73: e.g.: ::
74:
75: compress.cache-dir = "/var/www/cache/"
76:
77: # even better with virt-hosting
78: $HTTP["host"] == "docs.example.org" {
79: compress.cache-dir = "/var/www/cache/docs.example.org/"
80: }
81:
82: Default: not set, compress the file for every request
83:
84: compress.filetype
85: mimetypes which might get compressed
86:
87: e.g.: ::
88:
89: compress.filetype = ("text/plain", "text/html")
90:
91: Keep in mind that compressed JavaScript and CSS files are broken in some
92: browsers. Not setting any filetypes will result in no files being compressed.
93:
94: NOTE: You have to specify the full mime-type! If you also define a charset, for example, you have to use "text/plain; charset=utf-8" instead of just "text/plain".
95:
96: Default: not set
97:
98: compress.max-filesize
99: maximum size of the original file to be compressed kBytes.
100:
101: This is meant to protect the server against DoSing as compressing large
102: (let's say 1Gbyte) takes a lot of time and would delay the whole operation
103: of the server.
104:
105: There is a hard upper limit of 128Mbyte.
106:
107: Default: unlimited (== hard-limit of 128MByte)
108:
109: Display compressed files
110: ========================
111:
112: If you enable mod_compress, and you want to force clients to uncompress and display compressed text files, please force mimetype to nothing.
113: Exemple :
114: If you want to add headers for uncompress and display diff.gz files , add this section in your conf : ::
115:
116: $HTTP["url"] =~ "\.diff\.gz" {
117: setenv.add-response-header = ( "Content-Encoding" => "gzip" )
118: mimetype.assign = ()
119: }
120:
121:
122: Compressing Dynamic Content
123: ===========================
124:
125: PHP
126: ---
127:
128: To compress dynamic content with PHP please enable ::
129:
130: zlib.output_compression = 1
131: zlib.output_handler = On
132:
133: in the php.ini as PHP provides compression support by itself.
134:
135: mod_compress of lighttpd 1.5 r1992 may not set correct Content-Encoding with php-fcgi. A solution to that problem would be:
136:
137: 1.disable mod_compress when request a php file::
138:
139: $HTTP["url"] !~ "\.php$" {
140: compress.filetype = ("text/plain", "text/html", "text/javascript", "text/css", "text/xml")
141: }
142:
143: 2.enable mod_setenv of your lighttpd::
144:
145: server.modules += ( "mod_setenv" )
146:
147: 3.manually set Content-Encoding::
148:
149: $HTTP["url"] =~ "\.php$" {
150: setenv.add-response-header = ( "Content-Encoding" => "gzip")
151: }
152:
153:
154: TurboGears
155: ----------
156:
157: To compress dynamic content with TurboGears please enable ::
158:
159: [/]
160: gzip_filter.on = True
161: gzip_filter.mime_types = ["application/x-javascript", "text/javascript", "text/html", "text/css", "text/plain"]
162:
163: in the config/app.cfg file in your TurboGears application. The above lines should already be in the file. You just need to remove the comment symbol in front of the lines to make them active.
164:
165: Django
166: ------
167:
168: To compress dynamic content with Django please enable the GZipMiddleware ::
169:
170: MIDDLEWARE_CLASSES = (
171: 'django.middleware.gzip.GZipMiddleware',
172: ...
173: )
174:
175: in the settings.py file in your Django project.
176:
177: Catalyst
178: --------
179:
180: To compress dynamic content with Perl/Catalyst, simply use the Catalyst::Plugin::Compress::Gzip module available on CPAN ::
181:
182: use Catalyst qw(
183: Compress::Gzip
184: ...
185: );
186:
187: in your main package (MyApp.pm). Further configuration is not required.
188:
189: }}}
190:
191:
192:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>