GZIP and Concrete5

Permalink 8 users found helpful
I have been working on my site load speed (as Google complains its slow)...discovered gzip but not how to use it....now this might be trivia to some of you, I know, but as a novice I thought this would be useful for other newcomers....

I found this on google and added it to my .htaccess file

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_can_negotiate Yes
mod_gzip_static_suffix .gz
AddEncoding gzip .gz
mod_gzip_update_static No
mod_gzip_command_version '/mod_gzip_status'
mod_gzip_keep_workfiles No

mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 500000
mod_gzip_maximum_inmem_size 60000
mod_gzip_min_http 1000

mod_gzip_handle_methods GET POST

mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
mod_gzip_item_exclude mime ^image/
mod_gzip_item_exclude file \.js$
mod_gzip_item_exclude file \.css$

mod_gzip_item_include file \.html$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.pl$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^httpd/unix-directory$

mod_gzip_dechunk Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary On
</IfModule>

Now I dont know if this is good/bad or otherwise, perhaps someone learned friend in the community can advise...

 
nickratering replied on at Permalink Reply
nickratering
It can be shorter, I've added this to my .htaccess file:
# compress text, html, javascript, css, 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


and check your site at :http://www.whatsmyip.org/http_compression/...

If your server doesn't support .htaccess, you can allso add the following code to the very first beginning of your C5 template, my header element looks like this:
<?php
ob_start("ob_gzhandler");
defined('C5_EXECUTE') or die(_("Access Denied."));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<meta ... etc

And check again!
and check your site at:http://www.whatsmyip.org/http_compression/...

update 5.4.1
ob_start("ob_gzhandler");

doesn't work no more...
Mnkras replied on at Permalink Best Answer Reply
Mnkras
add this: it will increase your yslow grade and google page speed grade by a lot:

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
ExpiresActive On
ExpiresDefault "access plus 30 days"
FileETag none
nickratering replied on at Permalink Reply
nickratering
OK, I'll try and test!
Thnx!
senshidigital replied on at Permalink Reply
senshidigital
Just realised my server had this option and my sites speeds have increases dramatically. My own site saved over 70% in file sizes.

Nice one!!
novelnova replied on at Permalink Reply
novelnova
Thank you very much.
Also found this useful link on gzip
http://betterexplained.com/articles/how-to-optimize-your-site-with-...
mikefatty replied on at Permalink Reply
mikefatty
hi Guys

Stupid question but should I just paste the above code in it .htcaccess located in my theme folder or do i need to go to the root folder?

/Mike
Steevb replied on at Permalink Reply
Steevb
Hi,

In root folder, you don't need another one!
mikefatty replied on at Permalink Reply
mikefatty
hi 55webdesign

I thought that one should place it in the htacces. (where you add her Pretty URLs) file located in my theme folder ex. concrete / themes / themename /, but is it the same as placing it in the root folder? :-)

Thanks again Mike ps. i think my site in running faster now .. but are not sure if it's just the cache :-)

/ Mike (major Noob! :-))
nerdess replied on at Permalink Reply
nerdess
I've added the code and if I check my website with the Firefox "Live HTTP header" plugin I do get "Content-Encoding: gzip" so gzip is switched on.

However, if I check my website on http://www.whatsmyip.org/http-compression-test/... orhttp://www.gidnetwork.com/tools/gzip-test.php... it says my site is not gzipped?! Have I missed something?

Thanks
Sissi
Steevb replied on at Permalink Reply
Steevb
What code have you added and where?

This is what is in my .htaccess.

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<FilesMatch "\.(js|css|php|eot|ttf|otf|svg|html|)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>

Which does two things, one for gzip and one for page speed.
nerdess replied on at Permalink Reply
nerdess
In my .htacess is the code that Mnkras posted and that is marked "green" above.....

Hmmmm...how do I actually ensure that the server is serving compressed versions of my file?!
Steevb replied on at Permalink Reply
Steevb
Sorry, but either your server is not set up properly or you need to change the .htaccess file.

All sites I run use my code above?

All servers have mod_deflate active, check with your hosting provider.
frankdesign replied on at Permalink Reply
Also note that for the method used in the green comment, mod_expires needs to be active too.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
This what I did to enable gzip on my site which is hosted on a 1and1 server,
Add this line to your htaccess file:
AddType x-mapp-php5 .php


create a php.ini file and add this line to it
zlib.output_compression = On

put the php.ini file in the root of your site (same place as the htaccess file)

And test it!
nicolechung replied on at Permalink Reply
Wow I just tried that and it works AMAZING. Fastest gzip I've had to date.

This should be in the how-tos.
Empraxis replied on at Permalink Reply
Empraxis
Wow. I owe Mnkras and all of you here a huge Thanks! This has improved my client's GTmetrix score from "D" to "A" with just these additions.

if it helps anyone else, I was getting a score of "F" until I added the following Expires, which increased Page Load Speed significantly:

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year”
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month”
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
mohamedkhalid replied on at Permalink Reply
Is there any solution for websites hosted on IIS Server ?? As IIS does not use .htaccess file the current solution is not feasible
Steevb replied on at Permalink Reply
Steevb
Have you tried the IIS manger?
Just open the IIS Manager > Click on the site > Then click on URL Rewrite > Import rules 
You can import the rules you have from the .HTACCESS to your IIS

This link might help: https://www.supinfo.com/articles/single/4737-using-the-htaccess-rule...
frankdesign replied on at Permalink Reply
Enabling gzip support massively increases the speed of any site. Users who are experiencing performance issues should check that it is active and working. It was not enabled by default on our WHM/CPanel installation.
lackadaize replied on at Permalink Reply
lackadaize
Does anyone know how to compress site files through an iss server? Should this work for that as well? I've tried these solutions but none of them shows that the file is gzipped when I check on....

http://www.whatsmyip.org/http-compression-test/...

I don't think .htaccess works with iis. I would make the changes suggested at....

technet.microsoft.com/en-us/library/cc771003(WS.10).aspx

but the host/server administrator won't give me access to cpanel or php.ini (If there even is one for IIS, I don't really know)

Any help would be much appreciated as my site is still fairly slow at times. You can view the site athttp://www.eclinicalsol.com
SignallHill replied on at Permalink Reply
I used Mnkras code in my .htaccess and worked great.BUT, I have several websites in my hosting account.When using the code in the a sub domain then it says no compression enabled.

Anyone here know how to fix this.

i have

maindomain.com (works)
sub.maindomain.com (not working)

Thanks in advance
mnakalay replied on at Permalink Reply
mnakalay
I went crazy for a while with Bluehost trying to figure out why everything was in place but files were not gzipped. Turns out bluehost only allows gzipping on some files (html I think) but not on scripts or css => pretty useless.

I am saying that because most shared hosts will tell you of course gzip is enabled and they won't tell you it's limited to the point of being useless.
JohntheFish replied on at Permalink Reply
JohntheFish
Compressing some kinds of files can have little or no effect on size and simply wastes processor time.

eg. Files that are already compressed such as zip files, jpeg files and many kinds of video and sound files.

The benefit of zipping of some uncompressed graphic files types can be marginal (better to use a compressed file type) and can be enormously expensive in processor time for large files.

Compression is most effective on text based file types because they have a lot of wastage and repetitive sequences in the their content.

Hence a host that prohibits compression of some kinds of files could actually be doing a good job.

Nevertheless, script and css files are types I agree should be zippable.