Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Mod_deflate and pre-compressed html files.

Posted on 2008-06-16
1
Medium Priority
?
663 Views
Last Modified: 2013-11-05
We are using Apache Mod_deflate to dynamically compress output to clients that can handle it. It works great, however most of our large archives are plain text files and we are running out of space.

While keeping the same file names and endings (i.e .html), we would like to serve both pre-compressed and not-compressed html pages (different pages, NOT the same page twice) at the same time, with the web serve able to a) distinguish if the file is compressed or not  and b) if the client can accept compressed files or not. And then make adjustments as necessary (uncompressing for clients who can't accept compressed files, or compressing files that clients can, etc.)

Ideally, for apache to serve:
 /index.html -> not compressed. Mod_deflate to compress for clients that can accept it or send plain for clients who can't accept compress files

and also serve

 /archiveda.html -> compressed. Mod_deflate bypassing compressing and serves the pre-compressed version to clients that can handle it OR uncompresses for clients that can not.

The pre-compressed files can be intermixed with no compressed files, so no solutions based on directories. Also, we cannot change the names of any files.

Ideally, the older mod_gunzip would seem like the solution, but is only for Apache 1.1. In the mod_deflate docs, it is suppose to bypass compressing already compressed files. We tried pre-compressing using gzip,compress and pack to no luck - the client gets giberish ascii text. I am also not sure that even if we get it to bypass compressing pre-compressed files, that it would automatically decompress those files for clients who can't accept compressed docs.

Below is our current mod_deflate configuration in httpd.conf.
<Location />
# Insert filter
SetOutputFilter DEFLATE
 
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
 
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
 
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
 
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
 
 
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

Open in new window

0
Comment
Question by:surfsideinternet
1 Comment
 
LVL 27

Accepted Solution

by:
caterham_www earned 1500 total points
ID: 21947282
> We tried pre-compressing using gzip,compress and pack to no luck - the client gets giberish ascii text.

Wrong or missing encoding headers? See the AddEncoding directive. But mixing-up file extensions (.html sometimes encoded, sometimes not) won't work, I think, unless the content-encoding header is being set accordingly. Or they're compressed twice now (may be caused due to a missing content-encoding response header).

> Also, we cannot change the names of any files.

But you'll need to send a proper content-encoding header. AddEncoding expects extensions.

> Mod_deflate bypassing compressing

This is done by mod_deflate, if you have a header like 'content-encoding: gzip' present.

> and serves the pre-compressed version to clients that can handle it OR uncompresses for clients that can not.

mod_deflate can uncompress a compressed response body, too.

    SetOutputFilter INFLATE

But unfortunately the directive 'SetOutputFilter' does not accept an ENV like
   SetEnvIf ....... uncompress
   SetEnvIf ....... uncompress
   SetOutputFilter INFLATE env=uncompress

You'll need to modify httpd's source code here in order to accept such a syntax or create some AddOutputFilterByEnv. AddOutputFilterByType accepts only MIME types.

mod_ext_filter may be another option, too.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question