peps03
asked on
enable gzip compression via .htaccess
Hi,
I've search the internet for a while now, and i can't get the compression working for my website.
Or my hosting provider doesn't support it, or i'm using the wrong code, or i'm doing it wrong.
results on gzip from phpinfo():
_SERVER["HTTP_ACCEPT_ENCOD ING"]
gzip,deflate,sdch
HTTP_ACCEPT_ENCODING
gzip,deflate,sdch
Accept-Encoding
gzip,deflate,sdch
code i tried in .htaccess (2x):
Thanks!
I've search the internet for a while now, and i can't get the compression working for my website.
Or my hosting provider doesn't support it, or i'm using the wrong code, or i'm doing it wrong.
results on gzip from phpinfo():
_SERVER["HTTP_ACCEPT_ENCOD
HTTP_ACCEPT_ENCODING
Accept-Encoding
code i tried in .htaccess (2x):
# BEGIN GZIP
#<ifmodule mod_deflate.c>
#AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-httpd-php application/x-javascript application/javascript
#</ifmodule>
# END GZIP
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Thanks!
ASKER
From phpinfo():
Server API Apache 2.0 Handler
so i think you are right. but it doesn't work..
Server API Apache 2.0 Handler
so i think you are right. but it doesn't work..
Did you try the procedure described behind the link to get the installed modules?
--TheDoctor
--TheDoctor
ASKER
excuse me, didn't see that.
it returns:
Array ( [0] => core [1] => mod_log_config [2] => mod_logio [3] => itk [4] => http_core [5] => mod_so [6] => mod_actions [7] => mod_alias [8] => mod_auth_basic [9] => mod_auth_plain [10] => mod_authn_file [11] => mod_authz_default [12] => mod_authz_host [13] => mod_authz_user [14] => mod_autoindex [15] => mod_cgi [16] => mod_dir [17] => mod_env [18] => mod_expires [19] => mod_include [20] => mod_info [21] => mod_mime [22] => mod_mime_magic [23] => mod_reservefd [24] => mod_negotiation [25] => mod_php5 [26] => mod_rewrite [27] => mod_setenvif [28] => mod_ssl [29] => mod_status [30] => mod_suexec )
it returns:
Array ( [0] => core [1] => mod_log_config [2] => mod_logio [3] => itk [4] => http_core [5] => mod_so [6] => mod_actions [7] => mod_alias [8] => mod_auth_basic [9] => mod_auth_plain [10] => mod_authn_file [11] => mod_authz_default [12] => mod_authz_host [13] => mod_authz_user [14] => mod_autoindex [15] => mod_cgi [16] => mod_dir [17] => mod_env [18] => mod_expires [19] => mod_include [20] => mod_info [21] => mod_mime [22] => mod_mime_magic [23] => mod_reservefd [24] => mod_negotiation [25] => mod_php5 [26] => mod_rewrite [27] => mod_setenvif [28] => mod_ssl [29] => mod_status [30] => mod_suexec )
Hmm, seems you're out of luck since the modules are missing.
Can you check your provider if adding the mod is an option?
Alternatively, if youre building a php site, have a look here:
http://www.webcodingtech.com/php/gzip-compression.php
--TheDoctor
Can you check your provider if adding the mod is an option?
Alternatively, if youre building a php site, have a look here:
http://www.webcodingtech.com/php/gzip-compression.php
--TheDoctor
ASKER
2 bad for me..
yes, i am building a php site. does your script also compress css and js scripts that are include in the site like this:
<script src="./scripts/jquery.min. js" type="text/javascript"></s cript>
yes, i am building a php site. does your script also compress css and js scripts that are include in the site like this:
<script src="./scripts/jquery.min.
#
# mod_deflate options
#
# WARNING mime type here is type from extension,
# not from actual content type header
#
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript
SetEnvIfNoCase Request_URI ^/simeURLyouwanttoexclude/
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
#
DeflateCompressionLevel 3
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
#
Note - use mod_deflate, do NOT use mod_gzip. It is outdated and not maintained.
ASKER
Thanks a1j!
Do i only have to add this to my .htaccess? nothing else? Leave the rest of my page like it is?
what should i do with this line:
SetEnvIfNoCase Request_URI ^/simeURLyouwanttoexclude/ no-gzip !dont-vary
Thanks!!
Do i only have to add this to my .htaccess? nothing else? Leave the rest of my page like it is?
what should i do with this line:
SetEnvIfNoCase Request_URI ^/simeURLyouwanttoexclude/
Thanks!!
Hi again peps03,
if you want to compress any static content like css and js, you need to write a little
php-script based on the code on the linked webpage which gets the requested content, eg. main.css nad compresses it.
Then, with a mod_rewrite line in yout .htaccess, you can map a request on the /css location to that script.
--TheDoctor
if you want to compress any static content like css and js, you need to write a little
php-script based on the code on the linked webpage which gets the requested content, eg. main.css nad compresses it.
Then, with a mod_rewrite line in yout .htaccess, you can map a request on the /css location to that script.
--TheDoctor
ASKER
Hi Doc!
I now compressed the files manually as my hosting provider doesn't support that function.
I think i'm already using the script your talking about here: http://www.experts-exchang e.com/Prog ramming/La nguages/Sc ripting/CG I/Q_270314 47.html
but i'm having issues with that as you can read there.
Is this script what you meant?
Thanks!
I now compressed the files manually as my hosting provider doesn't support that function.
I think i'm already using the script your talking about here: http://www.experts-exchang
but i'm having issues with that as you can read there.
Is this script what you meant?
Thanks!
I dont know if it will work in .htaccess, you can try though.
You can delete that line, i added it as example.
You also have to add content type of your php files if you want to compress output from them.
You can delete that line, i added it as example.
You also have to add content type of your php files if you want to compress output from them.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
see last post
maybe you are running on Apche 2?
Try this...
Open in new window
If you can use php on your server and do not have console access, try this to get a list of modules
http://www.phpbuilder.com/manual/function.apache-get-modules.php
--TheDoctor