Jump to content

[SOLVED] Compressing Web Pages for Faster Load Times


Recommended Posts

In order to Optimize Your Site Using Compression, my hosting provider asked me to: Add the following code to the very top of your Web pages above the DOCTYPE:

 

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

 

This code is added where? header.tpl? Adding that before DOCTYPE won't trigger quirks mode?

 

Thanks and best regards,

 

AJ

Link to comment
Share on other sites

let's assume for a second that since they asked you to put this code in that mod_deflate is actually installed on your server.

 

Then add this (for example) to you .htaccess file. You can do this from the back office, preferences-->performance...pastE this or something similar into the box and click generate .htaccess

 

I am assuming you have a 1.4+ system. If not or the box is not there to paste the code, then just edit your .htaccess and paste it in.

 

# FROM A 1.4.6.2 PS GENERATION
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

 

read on

Link to comment
Share on other sites

Parse! Thanks for replying brother! I am also assuming it's installed on the server since all they send me was this link.

 

So I am just gonna add the code:

 

# FROM A 1.4.6.2 PS GENERATION

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE text/javascript

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

</IfModule>

On the very top of my .htaccess file right? It gets called on every page? Is there a way to know if it's working? Thanks mijo!

 

AJ

Link to comment
Share on other sites

Dude I was actually reading the documentation on the link I sent you above and they ask to insert this code on the top of my webpages, imagine going one by one hahaha ...

 

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

 

So the code you sent me above replaces this one by adding it to the .htaccess file right? You achieve the same compression? Or am I missing something here? This php string still should be inserted on the header.tpl?

Link to comment
Share on other sites

...the mod_deflate works at the apache level via either the httpd.conf or via definitions in the .htaccess. The php string you mention would not be needed with 1) httpd.conf or 2) .htaccess change. If the code already exists in your .htaccess and you are not getting compression, then the required module is not loaded.

Link to comment
Share on other sites

So I was able to know down 7 seconds by simply removing the accordion slide show and leaving only the nivo slider.

 

So in order to close this post, let's sum up:

 

- If your server ha enable gzip compression you should definitely do it.

- Add the following code into your .htaccess file:

 

# FROM A 1.4.6.2 PS GENERATION

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE text/javascript

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

</IfModule>

 

- Check if your site is compressing by visiting ths link. You'll get instant results on percentage compressed, etc.

 

Special thanks to el patron for collaborating on this subject! Happy selling!!!

 

AJ

Link to comment
Share on other sites

To me, the tool above gives the error :

"Sorry, I am unable to decompress the contents of this page. Possible bogus gzip/deflate encoded data."

What could that mean ?

I've checked the .htaccess and seems all right !

Hi Rhobur,

 

This topic has been marked solved. You would be better served by the community by opening a new thread with your description.

Link to comment
Share on other sites

Hi dude,

 

Indeed opening a new topic would be better as there's probably a bunch of people having the same error. Open a new topic ("gzip compression unable to decompress" or something like that) and in the mean time check the official site of gzip compressing.

 

If they solve your issue, still post it on the forum as it could be helpful to other members. Good Luck!

 

Best Regards,

 

AJ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...