tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Tapestry > Response Compression
Date Wed, 16 Jun 2010 12:32:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/8/_/styles/combined.css?spaceKey=TAPESTRY&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/TAPESTRY/Response+Compression">Response
Compression</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~uli">Ulrich
Stärk</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="ResponseCompression-ResponseCompression"></a>Response
Compression</h1>

<p>Starting in Tapestry 5.1, the framework automatically GZIP compresses content streamed
to the client. This can signifcantly reduce the amount of network traffic for a Tapestry application,
at the cost of extra processing time on the server to compress the response stream.</p>

<p>This directly applies to both rendered pages and streamed assets from the classpath.</p>

<p>Context assets will also be compressed ... but this requires referencing such assets
using the "context:" binding prefix, so that generated URL is handled by Tapestry and not
the servlet container.</p>

<h1><a name="ResponseCompression-CompressionConfiguration"></a>Compression
Configuration</h1>

<p>Small streams generally do not benefit from being compressed; there is overhead when
using compression, not just the CPU time to compress the bytes, but a lot of overhead. For
small responses, Tapestry does not attempt to compress the output stream.</p>

<p>The configuration symbol <tt>tapestry.min-gzip-size</tt> allows the cutoff
to be set; it defaults to 100 bytes.</p>

<p>In addition, some file types are already compressed and should not be recompressed
(they actually get larger, not smaller!). The service <span class="error">&#91;ResponseCompressionAnalyzer|../apidocs/org/apache/tapestry5/services/ResponseCompressionAnalyzer.html&#93;</span>'s
configuration is an unordered collection of content type strings that should <em>not</em>
be compressed. The default content types are "image/jpeg".</p>

<p>The mapping from file type (by extension) to content type is typically done as part
of your servlet-containers configuration. Alternately, you can contribute to the ResourceStreamer
service's configuration. This is a mapped configuration; it maps file extensions (such as
"css" or "js") to content types ("text/css" or "text/javascript") respectively.</p>

<h1><a name="ResponseCompression-StreamResponse"></a>StreamResponse</h1>

<p>When returning a <span class="error">&#91;StreamResponse|../apidocs/org/apache/tapestry5/StreamResponse.html&#93;</span>
from a <a href="#ResponseCompression-pagenav.html">component event method</a>,
the stream is totally under your control; it will not be compressed. You should use the ResponseCompressionAnalyzer
service to determine if the client supports compression, and add a java.util.zip.GZIPOutputStream
to your stream stack if compression is desired.</p>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/TAPESTRY/Response+Compression">View
Online</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message