TsgcWebSocketHTTPServerProperties › HTTPCompression

HTTPCompression プロパティ

Compresses HTTP/1.1 responses with gzip or deflate when the client advertises support, for both DocumentRoot static files and dynamic OnCommandGet responses.

構文

property HTTPCompression: TsgcHTTPCompression_Options read FHTTPCompression write SetHTTPCompression;

デフォルト値

Enabled=False

解説

既定では、サーバーはすべての HTTP/1.1 レスポンスを非圧縮で送信します。HTTPCompression.EnabledTrue に設定すると、クライアントの Accept-Encoding リクエストヘッダーが許可する場合に、対象となるレスポンスを gzip または deflate で圧縮します。Level は圧縮レベルで、0 から 9 まで指定できます(既定値は 6)。MinSize は、これより小さいバイト数のレスポンスの圧縮をスキップします(既定値は 1,024)。小さな本文を圧縮しても CPU コストに見合わないことが多いためです。Algorithms は、サーバーが使用できるエンコーディングの集合です(既定は caGZipcaDeflate の両方で、クライアントが両方を受け入れる場合は gzip が優先されます)。ContentTypes は、どのレスポンスのコンテンツタイプが対象になるかを列挙したもので、text/* のようなワイルドカードもサポートされ、既定値は一般的な text、JSON、JavaScript、XML、SVG の各タイプです。

The server never compresses a response that already has a Content-Encoding header, a 204/304/1xx status code, or a text/event-stream (Server-Sent Events) content type, and it skips compression when the compressed result would not actually be smaller. When it compresses a response it sets Content-Encoding and adds a Vary: Accept-Encoding header. This property covers HTTP/1.1 responses only; HTTP/2 responses are not affected. See HTTP Compression for a full explanation and how it differs from WebSocket message compression.

使用例


oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.DocumentRoot := 'C:\inetpub\wwwroot';
oServer.HTTPCompression.Enabled := true;
oServer.HTTPCompression.MinSize := 1024;
oServer.Active := true;

プロパティに戻る