Forum Moderators: phranque
I recently upgraded to Apache 2 on my server, previously I had Apache 1.3 and mod_gzip compression working fine. I have completed most of the configuration *I think* as all the .js .css files are reported back as compressed from YSlow & WhatsMyIP dot org, but my HTML files are still shown as not gzipped!
An example of the URL is domain.com/dir1/param1-param2-param3-param4.html
In my httpd.conf I have the following:
<IfModule mod_deflate.c>
<FilesMatch "\.(css¦js¦x?html?¦jsp¦txt)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
My server root .htaccess has the following:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 3600 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
ExpiresByType text/html "access plus 3600 seconds"
ExpiresByType application/xhtml+xml "access plus 3600 seconds"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico¦jpe?g¦png¦gif¦swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(css)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(js)$">
Header set Cache-Control "max-age=216000, private"
</FilesMatch>
<FilesMatch "\.(x?html?¦php)$">
Header set Cache-Control "max-age=3600, private, must-revalidate"
</FilesMatch>
</IfModule>
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
<IfModule mod_headers.c>
Header unset Last-Modified
</IfModule>
In my dir1 directory I have the following .htaccess rewrite rule:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ /execute/nav/navigate?cmd=getNavigate&cta=$1 [L]
Any help is greatly appreciated.
With thanks in advance
-Gs
Yes that would describe what is going on. Is there a way that i can also (seems silly) also include the extensionless URL's in the FilesMatch? Also as the server is passing back something without an extension - what file type would this fall into -- a txt file? Or is there a way to replace the FilesMatch with another condition to account for this again extensionless URL?
Sorry also forgot to include that the navigate class is written in Java which forwards the action using struts tiles to a JSP page where my dir1 Rewrite 's a friendly URL
With thanks
-George
[edited by: Alternative_Future at 3:40 pm (utc) on May 23, 2009]
I'd suggest giving your navigate script file a 'custom' file extension, and marking that file extension for compression.
You will also have to declare it executable, and parse it for whatever language it's actually written in.
That is, by renaming navigate.cgi to navigate.ccgi and including "ccgi" in your filesmatch, you will enable compression on its output. But you will also 'break' all of the other default .cgi configuration for this file, since its now a .ccgi file. So, you'll have to tell the server that it's executable, and tell it that it should parse .ccgi files as .pl or .php, or whatever language it's actually written in...
Actually, if you want to compress the output of all scripts of the original type, then just include that filetype in the filesmatch -- I assumed that this is not the case. And of course, I can't tell what the actual script filetype is, because it's obviously being rewritten from an extensionless URL to a 'real' filepath with an extension somewhere else in your code.
There may be a simpler way to do this and hopefully, someone will point it out if there is.
Jim