0

.htaccess

<ifmodule mod_deflate.c>
# compress the files
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

# removes some bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</ifmodule>

And for the php files

 <?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
ob_start("ob_gzhandler"); else ob_start(); ?>

And for the php files everything is OK but no for css,js files. Any tips ?

3
  • Silly question.. did you actually enable mod_deflate? The above configures stuff if and only if mod_deflate is loaded.. Commented Feb 20, 2012 at 2:16
  • Yes i have SetOutputFilter DEFLATE Commented Feb 20, 2012 at 2:21
  • I guess faux is taking about setting in httpd.conf did you have mod_deflate enabled Commented Feb 20, 2012 at 2:26

2 Answers 2

3

To test that mod_deflate is ACTUALLY working, try putting this at the top of your httpd.conf file:

LoadModule deflate_module modules/mod_deflate.so

and in the bottom of your httpd.conf file:

##############################################
#Mod Deflate Config:
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '(%{ratio_info}n%%) "%r" %{output_info}n/%{input_info}n' deflate
CustomLog logs/compression.log deflate
###############################################

This will compress just about anything ONLY if the browser sends the gzip-ready header.

After you get some hits on your site, check "compression.log" in the apache logs folder. Post the output.

Sign up to request clarification or add additional context in comments.

5 Comments

When i put LoadModule deflate_module modules/mod_deflate.so this in the .htaccess it says 500 Internal Server Error
Can you check you even have the file? Open apache/modules/ and see if it indeed exists. (Check error.log and post output please too). And make sure you only call it once, if you already have that line enabled then don't add another.
I dont have access to that .. witch mean i have to write to the hosting company
May I ask what company, then? Because if it's a real hosting company, look into mod_gzip, which is better at compressing files.
yeah is real is the best company in our country :D
1

In httpd.conf make sure this line is not commented

LoadModule deflate_module modules/mod_deflate.so

if it is then uncomment it and restart the apache service

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.