2

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>
sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
z1_jabbar
  • 21
  • 2

1 Answers1

1

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

Andrew M.
  • 10,982
  • 2
  • 34
  • 29