Click here to Skip to main content
15,909,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i have a website for which i want to compress all my html files. the hosting company i am with only supports 'zlib' compression but i have no idea how it works as i have tried the codes below in .htaccess file but none of them seem to work.

so can you help me please

thanks in advance to all helpers

amir

p.s these are the codes i have tried:

XML
FilesMatch "\.(php|html)$">
SetOutputFilter DEFLATE
</FilesMatch>


XML
AddOutputFilterByType DEFLATE text/html text/plain text/xml
and

XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript 


i have tried the following but that just crashes my site:

XML
<FilesMatch "\.(php|html?)$">
php_value zlib.output_compression 4000
</FilesMatch>
Posted
Updated 10-Jun-11 5:52am
v2

Are you sure it's not working for html files? In a browser you should not notice any difference between a compressed and uncompressed page, except it might download a bit faster. Looking at the headers in something like Firebug should show that the page has a "Content-Encoding: gzip" header.

You can turn compression on for individual PHP pages using this code:

PHP
<?php
ini_set('zlib.output_compression', TRUE);

// your code here ...
 
Share this answer
 
Comments
hamza_786 10-Jun-11 15:11pm    
i have tested whether my site is compressed or not using firebug and the result is that it is not compressed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900