Forum Moderators: phranque

Message Too Old, No Replies

Issues Using mod deflate to compress PHP documents

mod_deflate compression, gzip compression, php compression

         

TeamSDA

1:47 am on Apr 12, 2011 (gmt 0)

10+ Year Member



Hi All,

Below is what I am using on my .htaccess file. The bottom part of the code is what I am using to compress using mod_deflate. There seems to be an issue compressing my php documents. I have included a link below with the site that won't compress.


Link To Site:(sutherlanddesignagency.com/contact.php)



ErrorDocument 404 /errorpage.html

RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html(\?[^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>



Thank you for your help,

Christian

TeamSDA

10:38 pm on Apr 12, 2011 (gmt 0)

10+ Year Member



Does anyone have any input on this?

Christian

mslina2002

10:51 pm on Apr 12, 2011 (gmt 0)

10+ Year Member



Try changing ifmodule to ifModule (with capital M)

Perhaps that makes a difference

TeamSDA

3:56 pm on Apr 13, 2011 (gmt 0)

10+ Year Member



Hi Mslina2002,

Thank you for the suggestion, but unfortunately that didn't fix the compression issue. Any other ideas.


Thank you for your help,

Christian

jdMorgan

4:08 pm on Apr 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest simplifying your test case. Either attempt to compress only one type of file, or create a "fake" type of file to be compressed and test only with that filetype to get your code working.

Another approach is to create a static html page and test it. Will your code cause it to be compressed as it should?

Sometimes the module execution order is such that compression is invoked before php is interpreted, so no php-generated html gets compressed. That's a server configuration issue. The "hierarchy" must be:

Incoming client request
Check for cached version of php-generated HTML page
HTML page generation by php if required
Caching of somewhat-static HTML page
Check for pre-existing compressed version of HTML page
Compression of HTML page if required
Caching of compressed somewhat-static HTML page
Output cached and compressed content when possible

This is of course a very rough outline. Details that must be addressed include how to determine if a page should be cached (is it a relatively static page?) and whether it is still "current enough" even if it is somewhat static.

Jim