-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
I had a second look and found a tomcat configuration that seems to work:
in server.xml add the 3 compressionXXX parameters which will enable compression of svg responses. I didn't enable any other mime types since ZK enabling gzip compression by default for many other resource responses (css/js/zul) - to avoid double gzipping (see configuration reference on ZK AU Engine, ZK Loader and if enabled DSP Loader).
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressableMimeType="image/svg+xml"
compressionMinSize="0"
/>
I tested the following zul file on a tomcat 8 with the configuration above:
<zk>
<image id="chartImage"></image>
<zscript><![CDATA[
import org.zkoss.image.AImage;
import org.zkoss.util.media.AMedia;
AImage aImage = new AImage("chart1.svg", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\"/></svg>".getBytes());
desktop.getDynamicMediaURI(chartImage, "chart1.svg");
chartImage.setContent(aImage);
]]></zscript>
</zk>
This url was generated:
Request URL:http://localhost:8080/mytestapp/zkau/view/z_2zl/dMAP0/hhh1/1/c/chart1.svg
As you can see in the headers the compression was enabled:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
Content-Type: image/svg+xml;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 23 Feb 2017 01:09:58 GMT
I hope this information helps
2 | No.2 Revision |
I had a second look and found a tomcat configuration that seems to work:
in server.xml add the 3 compressionXXX parameters which will enable compression of svg responses. I didn't enable any other mime types since ZK enabling gzip compression by default for many other resource responses (css/js/zul) - to avoid double gzipping (see configuration reference on ZK AU Engine, ZK Loader and if enabled DSP Loader).
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressableMimeType="image/svg+xml"
compressionMinSize="0"
/>
I tested the following zul file on a tomcat 8 with the configuration above:
<zk>
<image id="chartImage"></image>
<zscript><![CDATA[
import org.zkoss.image.AImage;
import org.zkoss.util.media.AMedia;
AImage aImage = new AImage("chart1.svg", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\"/></svg>".getBytes());
desktop.getDynamicMediaURI(chartImage, "chart1.svg");
chartImage.setContent(aImage);
]]></zscript>
</zk>
This url was generated:
Request URL:http://localhost:8080/mytestapp/zkau/view/z_2zl/dMAP0/hhh1/1/c/chart1.svg
As you can see in the headers the compression was enabled:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
Content-Type: image/svg+xml;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 23 Feb 2017 01:09:58 GMT
I hope this information (even if only tomcat specific) helps
Robert
3 | No.3 Revision |
I had a second look and found a tomcat configuration that seems to work:
in server.xml add the 3 compressionXXX parameters which will enable compression of svg responses. I didn't enable any other mime types since ZK enabling gzip compression by default for many other resource responses (css/js/zul) - to avoid double gzipping (see configuration reference on ZK AU Engine, ZK Loader and if enabled DSP Loader).
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressableMimeType="image/svg+xml"
compressionMinSize="0"
/>
I tested the following zul file on a tomcat 8 with the configuration above:
<zk>
<image id="chartImage"></image>
<zscript><![CDATA[
import org.zkoss.image.AImage;
import org.zkoss.util.media.AMedia;
AImage aImage = new AImage("chart1.svg", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\"/></svg>".getBytes());
desktop.getDynamicMediaURI(chartImage, "chart1.svg");
chartImage.setContent(aImage);
]]></zscript>
</zk>
This url was generated:
Request URL:http://localhost:8080/mytestapp/zkau/view/z_2zl/dMAP0/hhh1/1/c/chart1.svg
As you can see in the headers the compression was enabled:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
Content-Type: image/svg+xml;charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 23 Feb 2017 01:09:58 GMT
I hope this information (even if only tomcat specific) helps for your application.
Update: another (less global) way is to implement a Servlet Filter with a filter-mapping for only /zkau/view/* and then apply the compression manually only when needed based on your own specific rules.
Robert