Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using following code, when i access site it only compress all the jsp inside all the urls path under /abc but it ignores all the js and css files. I want to compress js and css files under all the subfolders in /abc path? How I can do this. Thanks!

<LocationMatch "/abc">

  <IfModule mod_deflate.c>
  SetOutputFilter DEFLATE

  # Don't compress images
   SetEnvIfNoCase Request_URI \
   \.(?:gif|jpe?g|png)$ no-gzip dont-vary

 #Don't compress PDFs
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

 #Don't compress compressed file formats
 SetEnvIfNoCase Request_URI \.(?:7z|bz|bzip|gz|gzip|ngzip|rar|tgz|zip)$ no-gzip dont-vary

    <IfModule mod_headers.c>
      Header append Vary User-Agent
    </IfModule>
  </IfModule>
</LocationMatch>
share|improve this question
add comment

1 Answer

Why not try something like this?

<Location /abc>
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI \ .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:7z|bz|bzip|gz|gzip|ngzip|rar|tgz|zip)$ no-gzip dont-vary
</Location>

mod_deflate will ONLY compress things that have the OutputFilter set to DEFLATE. If you define this inside a Location or Directory tag, then mod_deflate will only look under those areas. In the above example, this will ONLY apply to folders under the relative url /abc.

Andrew

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.