Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 23rd May 2012, 16:49
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 395
Thanks: 30
Thanked 58 Times in 50 Posts
Default Preventing dynamically-served files from being gzipped (with clean URLs)

Hello,

I (and others) have come to realize that IE 6/7/8 will double-compress any already-compressed file -- and fail to double-de-compress it -- when gzip compression is enabled for, e.g., a ZIP file download.

To work around this limitation, I need to have some means by which to exclude certain URLs from compression.

On its face, this seems simple enough, but this particular application requires the use of so-called "clean URLs". As such, Apache's SetEnvIf module seems not to be able to access the "clean URL"; it always sees "/index.php" for the "Request_URI".

I have this mod_rewrite rule:

Code:
# Rewrite URLs of the form 'index.php?q=x':
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
I was hoping to be able to force no-gzip with something like this:

Code:
SetEnvIfNoCase Request_URI (.*)(/|download/.*)$ no-gzip dont-vary
The idea is that anything that is in a "download" directory does not receive gzip compression (which is enabled site-wide).

The problem is that the SetEnvIf directive is never satisfied because, as stated above, Request_URI always equals the "true" URI, as it exists before the clean URL" rewriting is performed: "/index.php".

I considered using mod_rewrite to modify the CGI environment variables, but I don't like that solution because a) it very likely wouldn't work when PHP is running under Mod-PHP (as opposed to Fast-CGI), it wouldn't work if SuPHP is in use, and it may not even be possible to modify the "no-gzip" environment variable; the Apache docs state: "It is not possible to override or change the standard CGI variables using the environment manipulation directives."

Does anyone have any other ideas?

EDIT to add: This kind of thing doesn't work, for the reasons outlined above:

Code:
# Don't compress images (or other files that are already compressed)
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|zip|7z|rar|sit?x|mp3|flac|ogg|pdf)$ no-gzip dont-vary

Last edited by cbj4074; 23rd May 2012 at 16:55.
Reply With Quote
Sponsored Links
  #2  
Old 24th May 2012, 14:33
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
 
Default

You can try this:
Code:
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
See http://www.howtoforge.com/apache2_mod_deflate
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Tags
apache, cgi, gzip, mod_rewrite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacked server Captain Installation/Configuration 8 23rd December 2010 11:39
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 18:26
Debian 5.0 'hangs' GHz Installation/Configuration 5 1st October 2009 13:57
The system is currently updating the configuration files. warlock General 8 21st February 2009 19:15
Network questions regarding Ubuntu Server lubod Installation/Configuration 7 3rd January 2007 19:53


All times are GMT +2. The time now is 08:06.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.