Hi Chris,
Am 10.03.2015 um 15:09 schrieb Christopher Schultz:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Rainer,
On 3/9/15 7:01 PM, Rainer Jung wrote:
Am 09.03.2015 um 23:11 schrieb Christopher Schultz:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Igor,
On 3/9/15 6:01 PM, Igor Cicimov wrote:
On 10/03/2015 6:14 AM, "Victor Rodriguez"
<victropo...@gmail.com> wrote:
Greetings,
I have some ALREADY gzipped files that I'm trying to serve
up.
I have the following in my web.xml.
<mime-mapping> <extension>json</extension>
<mime-type>application/gzip</mime-type> </mime-mapping>
And, I have the following in my server.xml:
<Context docBase="/path/to/already-gzipped-json"
path="/already-gzipped-json" />
From the command line, I can curl the files and gunzip them
just fine, so they are coming across gzipped:
curl http://localhost:8082/already-gzipped-json/fie.json |
gunzip -
However, requests coming from a web browser aren't handled
correctly and aren't legible in the browser, and I believe
it's because
Content-Encoding:
gzip is not in the response headers.
You mean Accept-Encoding, right? Is tomcat fronted by apache,
nginx or something else that can add this header for you?
Ironically, getting this to work as requested in Apache httpd is
a complete nightmare. The Tomcat solution basically works
*exactly* as a user would want it to work.
Agreed, that the feature in the default servlet is much much easier
to use than configure pre-compressed content in httpd. But
nightmare might be a bit to strong. It is tricky. See for example:
http://mail-archives.apache.org/mod_mbox/httpd-users/201110.mbox/%3c4e8e51c0.4050...@kippdata.de%3E
Would
you be up for the creation of mod_already_gzipped? It could act
just like the DefaultServlet's behavior:
1. Did the client say it could Accept-Encoding: gzip?
2. Does the file [translated-path].gz exist?
3. Then send those bytes with Content-Encoding: gzip and
Content-Length: size(file.gz)
It seems like that should be a no-brainer in terms of functionality.
Using MultiViews and re-naming your files to bizarre filenames, etc.
is a big hack that I finally decided wasn't worth it.
Note that the linked recipe I provided for httpd does not use MultiViews
and also does not force you to rename the existing (uncompressed) files.
It contains 5 lines of Apache config, of which 2 are most likely already
present. So it boils down to one RewriteRule plus RewriteCond and one
mod_headers directive. How and why it works is the long part of the
description.
The only other thing is the maybe uncommon policy for the names of the
*compressed* files, keeping the ".gz" in front of the original file name
suffix. You could even move it completely in front of the file name like
gz.myfile.suf to make it even more uncommon ;)
But yes, the recipe still needs to be adjusted depending on where your
static files are, for which files you want to use it etc. So packing it
into a simple module could be worthwhile. I'll post it if I get to it.
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org