Skip to:
Content
Pages
Categories
Search
Top
Bottom

Enable gzip compression

Viewing 20 replies - 1 through 20 (of 20 total)

  • Michael
    Participant

    @michael888

    Depends on where you’re hosting your site. If you’re running a free web host, then it most likely appends analytics code at the end of each page. The analytics system for most of these servers are very slow. If this is the case, add the following to your .htaccess file on the root of your public_html folder (if it does not exist, then you should create the file):

    php_value auto_append_file none
    php_value auto_prepend_file none

    Also, if your host (free or not) has ZLib compression enabled, you can add the following to your .htaccess file:

    <ifmodule mod_php5.c>
    php_value zlib.output_compression 16386
    </ifmodule>

    That will compress the output of your site quite a bit.

    My forum (http://www.inniosoft.co.cc/devstation) used to take longer than a minute to finish loading. After adding that, it is much quicker.

    There are no plugins that I’m aware of that do this for bbPress, so the above implementation would be best for now.

    Hope that helps a little. :)


    citizenkeith
    Participant

    @citizenkeith

    Wow, I’ve been using bbPress for 2 years and never saw any mention of the effects of analytics code.

    Before changing htaccess:

    0.518 – 15 queries

    After:

    0.146 – 15 queries

    (and lower)


    Michael
    Participant

    @michael888

    Glad it helped. :)


    Olaf Lederer
    Participant

    @finalwebsites

    According Google most of my sites are slower than the rest according google, but the problem is mostly the google analytics code which takes a lot of time:

    They suggest:

    Enable gzip compression

    Compressing the following resources with gzip could reduce their transfer size by 19.9 KB:

    (what I have for my own server)

    and check the load time for GA:

    http://www.google-analytics.com/ga.js (13.6 KB)

    will say I will stop using Google (analytics) my site becomes much faster :(

    If 60-70% of the sites are much faster maybe only ~30 are using slow “google” code on their site?

    That’s … almost funny that GOOGLE is telling you THEIR script is slow.

    You’re using the ga.js, which is actually faster than urchin.js (the old script). I wouldn’t really worry about it, so long as Google Analytics is in the footer of your page. It could just be a bad load day for Google.


    chrishajer
    Participant

    @chrishajer

    ipstenu, what do you think about hosting ga.js locally and keeping it up to date?


    Ben L.
    Member

    @nightgunner5


    chrishajer
    Participant

    @chrishajer

    Nice new Avatar, Nightgunner5 :-)

    ipstenu, what do you think about hosting ga.js locally and keeping it up to date?

    Eh. I think unless it’s causing your site to be REALLY slow, it’s not needed. I’d take some metrics and compare to having ga loaded, not loaded and loaded locally and see how much speed we’re talking about.

    O-kay I’ve tried Ben L.’s suggestion, will see if any improvements come…

    <ifmodule mod_php5.c>
    php_value zlib.output_compression 16386
    </ifmodule>

    That didn’t work for me btw


    Michael
    Participant

    @michael888

    What version of PHP are you running? If you have PHP 4, then change mod_php5.c to mod_php4.c.

    You should also ensure that zlib is installed on your server.

    Where I can see that? In my cpanel? I’m on a shared hosting.


    Michael
    Participant

    @michael888

    You should be able to see the version of PHP on the sidebar of your cPanel. Your host will most likely have upgraded to 5 by now.

    You would also have to contact an administrator and ask if zlib is enabled. In most cases, it is.

    By the way, the compression doesn’t completely speed up your website, it simple increases it’s performance. In some cases, one would notice a speed difference.

    Is your website way too slow?


    chrishajer
    Participant

    @chrishajer

    You could also create a phpinfo file and access it from your browser:

    <?php
    phpinfo();
    ?>

    Save that in a file called info.php (or whatever you want) and then access it through your browser:

    http://www.example.com/info.php

    In there you will have your PHP version and also if compression is enabled.


    Michael
    Participant

    @michael888

    Just goes to show that I need to learn more PHP. Thanks for this, Chris. Quite handy. :)


    Milan Dinić
    Participant

    @dimadin

    Instead of loading zlib via .htaccess, you should use Apache’s built-in module mod_deflate because it is better for server’s performance. By using code below, you will compress all textual content from your site (html, css, javascript, rss). Simply remove type you don’t want to compress from list and it won’t compress after that. Note that you shouldn’t add any more types because other file types can’t be compressed this way.

    Just copy/paste this code in your .htaccess file in root of web site. You can use this on ANY kind of website, no matter if it is powered by bbPress or not. Just watch-out that some script you use doesn’t already compress some type, because it will than double compress which will be worse than using uncompressed type.

    Also note that on some bad configured servers this can make additional load on servers so be careful (this applies to zlib comrpession too).

    <IfModule mod_deflate.c>

    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/x-javascript application/x-httpd-php application/rss+xml application/atom_xml

    </IfModule>

    You can test your site before and after with tools like WebPagetest (just click on images on result’s page for detailed information) and Web Page Analyzer. And share your results here.

    what do you think about hosting ga.js locally and keeping it up to date?

    You shouldn’t store popular JavaScript files (like from Google Analytics, AdSense, StatCounter etc) on your server because they are probably in visitors’ cache so he will not even load that files while visiting your site.

    This is because most sites nowadays use Google Analytics and when man without that file in cache visits page that use it, that file is saved in it’s cache for seven days (because Google gives information to browser in file’s HTTP headers) and it is not loaded again until it expires from cache.


    chrishajer
    Participant

    @chrishajer

    Just a quick note: mod_deflate is present on Apache 2.* series web servers, Apache 1.3.* uses mod_gzip. Thank you for the informative post, Милан Динић.


    Milan Dinić
    Participant

    @dimadin

    Yes, I forgot to mention that. Though I think that Apache 2.* is mostly used now.

    Is there any reason why this code (from Milan Dinic) does not work for me on apcahe 2, and php5.x?

Viewing 20 replies - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.
Skip to toolbar