]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_deflate.xml.ja
docs: update
[apache] / docs / manual / mod / mod_deflate.xml.ja
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
4 <!-- English Revision: 420990:1793934 (outdated) -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <modulesynopsis metafile="mod_deflate.xml.meta">
24
25 <name>mod_deflate</name>
26 <description>クライアントへ送られる前にコンテンツを圧縮する</description>
27 <status>Extension</status>
28 <sourcefile>mod_deflate.c</sourcefile>
29 <identifier>deflate_module</identifier>
30
31 <summary>
32     <p><module>mod_deflate</module> モジュールは <code>DEFLATE</code>
33     出力フィルタを提供します。これはサーバからの出力を、ネットワークを
34     通してクライアントに送る前に圧縮することを可能にします。</p>
35 </summary>
36 <seealso><a href="../filter.html">Filters</a></seealso>
37
38 <section id="recommended"><title>サンプル設定</title>
39     <p>下にせっかちな人向けの簡単な設定例を示します。</p>
40
41     <example><title>数タイプのみ圧縮する</title>
42       AddOutputFilterByType DEFLATE text/html text/plain text/xml
43     </example>
44
45     <p>以下の設定はコンテンツをより圧縮しますが、ずっと複雑な設定になります。
46     設定の隅々までよく理解しないで使わないでください。</p>
47
48     <example><title>画像以外全て圧縮する</title>
49       &lt;Location /&gt;<br />
50       <indent>
51         # Insert filter<br />
52         SetOutputFilter DEFLATE<br />
53         <br />
54         # Netscape 4.x has some problems...<br />
55         BrowserMatch ^Mozilla/4         gzip-only-text/html<br />
56         <br />
57         # Netscape 4.06-4.08 have some more problems<br />
58         BrowserMatch ^Mozilla/4\.0[678] no-gzip<br />
59         <br />
60         # MSIE masquerades as Netscape, but it is fine<br />
61         # BrowserMatch \bMSIE             !no-gzip !gzip-only-text/html<br />
62         <br />
63         # Don't compress images<br />
64         SetEnvIfNoCase Request_URI \<br />
65         <indent>
66           \.(?:gif|jpe?g|png)$ no-gzip dont-vary<br />
67         </indent>
68         <br />
69         # Make sure proxies don't deliver the wrong content<br />
70         Header append Vary User-Agent env=!dont-vary<br />
71       </indent>
72       &lt;/Location&gt;
73     </example>
74
75 </section>
76
77 <section id="enable"><title>圧縮を有効にする</title>
78
79     <section id="output"><title>Output Compression</title>
80       <p>圧縮機能は <code>DEFLATE</code> <a href="../filter.html">フィルタ</a>
81       により実装されています。以下のディレクティブはそのディレクティブのある
82       コンテナ中のドキュメントを圧縮するようにします:</p>
83       
84       <example>
85         SetOutputFilter DEFLATE
86       </example>
87
88       <p>よく使われているブラウザでは、すべてのコンテンツに対する
89       圧縮を扱えるわけではありません。ですから、<code>gzip-only-text/html</code> 
90       ノートを <code>1</code> にして、html ファイルに対してのみ
91       圧縮が働くようにした方がよいかもしれません (以下参照)
92       この値を <em><code>1</code> 以外の値</em>に設定した場合は無視されます。</p>
93       
94       <p>通常、特定のMIMEタイプについてのみ圧縮したいのであれば、
95       <directive module="core">AddOutputFilterByType</directive>
96       ディレクティブを使用します。次に Apache のドキュメントの html
97       ファイルのみの圧縮を有効にする例を示します。</p>
98
99       <example>
100         &lt;Directory "/your-server-root/manual"&gt;<br />
101         <indent>
102           AddOutputFilterByType DEFLATE text/html<br />
103         </indent>
104         &lt;/Directory&gt;
105       </example>
106
107       <p>全てのファイルタイプでの圧縮に問題を抱えているブラウザに対しては、
108       <directive module="mod_setenvif">BrowserMatch</directive>
109       ディレクティブを使用して、特定のブラウザに <code>no-gzip</code>
110       ノートをセットし、圧縮が行なわれないようにします。
111       <code>no-gzip</code> と <code>gzip-only-text/html</code>
112       を組み合わせることで上手く対処できます。
113       この場合、前者が後者をオーバーライドします。
114       上記の<a href="#recommended">設定例</a>の抜粋を
115       次に示しますのでご覧下さい。</p>
116
117       <example>
118         BrowserMatch ^Mozilla/4         gzip-only-text/html<br />
119         BrowserMatch ^Mozilla/4\.0[678] no-gzip<br />
120         BrowserMatch \bMSIE             !no-gzip !gzip-only-text/html
121       </example>
122
123       <p>まず始めに <code>User-Agent</code> 文字列から Netscape Navigator
124       4.x であるかどうかを調べます。これらのバージョンでは、
125       <code>text/html</code> 以外のタイプの圧縮を扱うことができません。
126       4.06, 4.07, 4.08 は html ファイルの伸張にも問題を抱えています。
127       ですからこれらに対しては、完全に deflate フィルタをオフにします。</p>
128
129       <p>3 番目の <directive module="mod_setenvif">BrowserMatch</directive>
130       ディレクティブで、推測したユーザーエージェントを修正します。
131       なぜなら Microsoft Internet Explorer も "Mozilla/4" と特定されますが、
132       これらは実際には圧縮を扱うことができるからです。
133       <code>User-Agent</code> ヘッダを "MSIE"
134       (<code>\b</code> は「単語の境界」を意味します) の追加文字で検査して、
135       これ以前に設定した制限を再び解除します。</p>
136
137       <note><title>注</title>
138         <code>DEFLATE</code> フィルタは必ず、PHP や SSI といった RESOURCE
139         フィルタの後になります。
140         DEFLATE フィルタは内部的なサブリクエストを関知しません。
141       </note>
142       <note><title>注</title>
143         <directive module="core">SetEnv</directive> で設定される
144         <code>force-gzip</code> 環境変数がありますが、これは
145         ブラウザの accept-encoding 設定を無視し、圧縮した出力をします。
146       </note>
147
148     </section>
149     <section id="inflate"><title>出力の伸長</title>
150       <p><module>mod_deflate</module> モジュールは、gzip 圧縮されたレスポンス
151       本文を inflate/uncompress するフィルタも提供しています。
152       この機能を有効にするには、<directive module="core">SetOutputFilter</directive>
153       や <directive module="mod_mime">AddOutputFilter</directive> を使って、
154       <code>INFLATE</code> フィルタを出力フィルタチェインに挿入します。
155       例えば次のようにします。</p>
156
157       <example>
158         &lt;Location /dav-area&gt;<br />
159         <indent>
160           ProxyPass http://example.com/<br />
161           SetOutputFilter INFLATE<br />
162         </indent>
163         &lt;/Location&gt;
164       </example>
165
166       <p>この例では、example.com からの gzip 圧縮された出力を伸長し、
167       その他のフィルタがさらにその出力を処理できるようにします。
168       </p>
169       
170     </section>
171     <section id="input"><title>入力の伸張</title>
172       <p><module>mod_deflate</module> モジュールは、gzip
173       で圧縮されたリクエスト本体を伸張するフィルタも提供しています。
174       この機能を有効にするには、<directive module="core">SetInputFilter</directive>
175       か <directive module="mod_mime">AddInputFilter</directive> を使用して、
176       <code>DEFLATE</code> フィルタを入力フィルタチェインに組み込みます。
177       例えば次のようになります。</p>
178
179       <example>
180         &lt;Location /dav-area&gt;<br />
181         <indent>
182           SetInputFilter DEFLATE<br />
183         </indent>
184         &lt;/Location&gt;
185       </example>
186       
187       <p>この設定であれば、<code>Content-Encoding: gzip</code>
188       ヘッダを含むリクエストが来ると、本体は自動的に伸張されます。
189       gzip リクエスト本体を送信するブラウザはあまりありません。
190       しかし、例えば <a href="http://www.webdav.org">WebDAV</a>
191       クライアントの幾つかなど、特別なアプリケーションでリクエストの
192       圧縮を実際にサポートしているものもあります。</p>
193
194       <note type="warning"><title>Content-Length に関する注意</title>
195         <p>リクエスト本体それ自体を評価する場合は、<em><code>Content-Length</code>
196         ヘッダを信用しないでください</em>。Content-Length ヘッダは、
197         クライアントから送信されるデータの長さを反映しているのであって、
198         伸張されたデータストリームの<em>バイトカウントではありません</em>。</p>
199       </note>
200     </section>
201 </section>
202
203 <section id="proxies"><title>Proxy サーバでの扱い</title>
204
205     <p><module>mod_deflate</module> モジュールは <code>Vary: Accept-Encoding</code>
206     HTTP 応答ヘッダを送信して、適切な <code>Accept-Encoding</code>
207     リクエストヘッダを送信するクライアントに対してのみ、
208     プロクシサーバがキャッシュした応答を送信するように注意を喚起します。
209     このようにして、圧縮を扱うことのできないクライアントに
210     圧縮された内容が送られることのないようにします。</p>
211
212     <p>もし特別に何かに依存して除外したい場合、例えば <code>User-Agent</code>
213     ヘッダなどに依存している場合、手動で <code>Vary</code> ヘッダを設定して、
214     追加の制限についてプロクシサーバに注意を行なう必要があります。
215     例えば <code>User-Agent</code> に依存して <code>DEFLATE</code>
216     を追加する典型的な設定では、次のように追加することになります。</p>
217
218     <example>
219       Header append Vary User-Agent
220     </example>
221     
222     <p>リクエストヘッダ以外の情報 (<em>例えば</em> HTTP バージョン)
223     に依存して圧縮するかどうか決める場合、
224     <code>Vary</code> ヘッダを <code>*</code> に設定する必要があります。
225     このようにすると、仕様に準拠したプロクシはキャッシュを全く行なわなくなります。</p>
226
227     <example><title>例</title>
228       Header set Vary *
229     </example>
230 </section>
231
232 <directivesynopsis>
233 <name>DeflateFilterNote</name>
234 <description>ロギング用に圧縮比をメモに追加</description>
235 <syntax>DeflateFilterNote [<var>type</var>] <var>notename</var></syntax>
236 <contextlist><context>server config</context>
237 <context>virtual host</context></contextlist>
238 <compatibility><var>type</var> is available since Apache 2.0.45</compatibility>
239
240 <usage>
241     <p><directive>DeflateFilterNote</directive> ディレクティブは
242     圧縮比に関するメモがリクエストに付加されることを指定します。
243     メモ (note) の名前はディレクティブに指定された値です。
244     メモは<a href="../logs.html#accesslog">アクセスログ</a>に
245     値を記録し、統計を取る目的にも使えます。</p>
246
247     <example><title>例</title>
248       DeflateFilterNote ratio<br />
249       <br />
250       LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate<br />
251       CustomLog logs/deflate_log deflate
252     </example>
253
254     <p>ログからもっと精密な値を抽出したい場合は、<var>type</var>
255     引数を使用して、データタイプをログのメモとして残すように指定できます。
256     <var>type</var> は次のうちの一つです。</p>
257
258     <dl>
259       <dt><code>Input</code></dt>
260       <dd>フィルタの入力ストリームのバイトカウントをメモに保存する。</dd>
261
262       <dt><code>Output</code></dt>
263       <dd>フィルタの出力ストリームのバイトカウントをメモに保存する。</dd>
264
265       <dt><code>Ratio</code></dt>
266       <dd>圧縮率 (<code>出力 / 入力 * 100</code>) をメモに保存する。
267       <var>type</var> 引数を省略した場合は、これがデフォルトとなります。</dd>
268     </dl>
269
270     <p>まとめると、次のようにログを取ることになるでしょう。</p>
271
272     <example><title>精密なログ採取</title>
273       DeflateFilterNote Input instream<br />
274       DeflateFilterNote Output outstream<br />
275       DeflateFilterNote Ratio ratio<br />
276       <br />
277       LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate<br />
278       CustomLog logs/deflate_log deflate
279     </example>
280 </usage>
281 <seealso><module>mod_log_config</module></seealso>
282 </directivesynopsis>
283
284 <directivesynopsis>
285 <name>DeflateBufferSize</name>
286 <description>zlib が一度に圧縮する塊の大きさ</description>
287 <syntax>DeflateBufferSize <var>value</var></syntax>
288 <default>DeflateBufferSize 8096</default>
289 <contextlist><context>server config</context>
290 <context>virtual host</context></contextlist>
291
292 <usage>
293     <p><directive>DeflateBufferSize</directive> ディレクティブは
294     zlib が一度に圧縮する塊の大きさをバイト単位で指定します。</p>
295 </usage>
296 </directivesynopsis>
297
298 <directivesynopsis>
299 <name>DeflateWindowSize</name>
300 <description>Zlib の圧縮用ウィンドウの大きさ</description>
301 <syntax>DeflateWindowSize <var>value</var></syntax>
302 <default>DeflateWindowSize 15</default>
303 <contextlist><context>server config</context>
304 <context>virtual host</context></contextlist>
305
306 <usage>
307     <p><directive>DeflateWindowSize</directive> ディレクティブは
308     zlib の圧縮用ウィンドウ (訳注: zlib で使用される履歴バッファ) 
309     の大きさを指定します (1 から 15 の間の値)。
310     一般的に大きなウィンドウサイズを使用すると圧縮率が向上します。
311     (訳注: 2 を底とする対数の値になります。
312     8 から 15 にするのが良いでしょう。)</p>
313 </usage>
314 </directivesynopsis>
315
316 <directivesynopsis>
317 <name>DeflateMemLevel</name>
318 <description>zlib が圧縮に使うメモリのレベルを指定</description>
319 <syntax>DeflateMemLevel <var>value</var></syntax>
320 <default>DeflateMemLevel 9</default>
321 <contextlist><context>server config</context>
322 <context>virtual host</context></contextlist>
323
324 <usage>
325     <p><directive>DeflateMemLevel</directive> ディレクティブは
326     zlib が圧縮に使うメモリのレベルを設定します (1 から 9 の間の値)。
327     (訳注: 2 を底とする対数の値になります。
328     8 程度が良いでしょう。)</p>
329 </usage>
330 </directivesynopsis>
331
332 <directivesynopsis>
333 <name>DeflateCompressionLevel</name>
334 <description>出力に対して行なう圧縮の程度</description>
335 <syntax>DeflateCompressionLevel <var>value</var></syntax>
336 <default>Zlib のデフォルト</default>
337 <contextlist><context>server config</context><context>virtual host</context>
338 </contextlist>
339 <compatibility>This directive is available since Apache 2.0.45</compatibility>
340
341 <usage>
342      <p><directive>DeflateCompressionLevel</directive> ディレクティブは
343          圧縮の程度を設定します。大きな値では、より圧縮が行なわれますが、
344          CPU 資源を消費します。</p>
345     <p>値は 1 (低圧縮) から 9 (高圧縮) です。</p>
346 </usage>
347 </directivesynopsis>
348
349 </modulesynopsis>
350