Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apache server

Posted on 2008-06-25
3
Medium Priority
?
306 Views
Last Modified: 2012-06-21
Hello, i am using mod_defalte module for compression at server end and i want to compress only css and js and uncompress rest of files only for browser IE 6.0 and i have used the following code which is not working please find code snippet attached.
LoadModule deflate_module @@APACHE_DIR@@/modules/mod_deflate.so
 
<Location />
                                                                                                                             
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/html
 
BrowserMatch \bMSIE/s6\.0 !no-gzip !gzip-only-text/css text/javascript
 
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.swf$ no-gzip dont-vary
                                                                                                                             
</Location>

Open in new window

0
Comment
Question by:kranthi_50404
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:ralphcarey
ID: 21897803
Hi,

This isn't a complete solution and I'm not an expert on Apache but I have been looking at compression over the last couple of days and found that the following lines work. They are less verbose than those you are currently using and so possibly easier to edit to meet your requirements:

##ZIP/DEFLATE/COMPRESS
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
Header append Vary User-Agent env=!dont-vary
##LOG FOR ZIP/DEFLATE/COMPRESS
DeflateFilterNote deflate_ratio
LogFormat "%v %h %l %u %t \"%r\" %>s %b mod_deflate: %{deflate_ratio}n pct." vhost_with_deflate_info
CustomLog /var/log/deflate_access_log vhost_with_deflate_info

The log lines are useful because they show how much pages are being compressed, but if you do not want to know then omit them.

0
 

Author Comment

by:kranthi_50404
ID: 21903922
well that is fine ... i specifically want to compress only css files for IE 6.0 and rest of the files should be uncompressed and for other browsers it should compress every thing except image file(png, gpeg..exc) and pdf files...the above code doesn't do that...
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 21958078
You may try the following snipped (mod_rewrite required).
LoadModule deflate_module @@APACHE_DIR@@/modules/mod_deflate.so
 
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4
RewriteCond %{HTTP_USER_AGENT} !MSIE
RewriteRule  ^ - [NS,E=gzip-only-text/html,L]
 
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0[678]
RewriteCond %{HTTP_USER_AGENT} !MSIE
RewriteRule  ^ - [NS,E=no-gzip,L]
 
RewriteCond %{HTTP_USER_AGENT} MSIE\ 6\.0
RewriteRule !\.(?:css|js)$ - [NS,E=no-gzip,L]
 
<Location />
AddOutputFilterByType DEFLATE text/plain text/xml text/css text/javascript text/html
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location> 

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

609 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