Drake CMS Official Forums - read-only archive

You are reading the Drake CMS Official Forums archive, available for historical purposes only.

Drake CMS has been rebranded into Lanius CMS, visit the new Lanius CMS Official Forums if you need support about Lanius CMS or Drake CMS -> Lanius CMS migration.



Home page General discussion > Apache optimization tricks (through .htaccess) Permanent link to this page
 
 
Author Message:
legolas558
Apache optimization tricks (through .htaccess)
06 June 2007 21:22
Anonymous Hi drakers,

I would like to share with you some knowledge about using the .htaccess configuration file for Apache. So, if you have a web hosting which has Apache installed (the fastest way to check this is to reach an url like http://www.example.com/yoursite/nonexistanturl and see the 404 page, which should report the server software) you can create (if the host allowed you to) an .htaccess file in the website root path of Drake CMS (but actually of any other PHP application) with this content, explained step by step:

Code:
## applies deflating to all textual responses
AddOutputFilterByType DEFLATE text/html text/plain text/xml

The above line (those with ## or # are comments) will active the mod_deflate on your Apache .htaccess configuration.

See http://httpd.apache.org/docs/2.0/mod/mod_deflate.html for more.

But, if your Apache has not that module installed, then you might use the PHP alternative:
Code:
## activates zlib compression
php_value zlib.output_compression 1
## you might want to enable also the following line to override the default level of 6
## do it ONLY if your server as low CPU power
# php_value zlib.output_compression 3


When using one of the above methods, you should turn off the Drake CMS gzip compression (that will not be used).

Remember that http compression is important, will decrease your bandwidth usage and offer faster page download times to your users.

You might get a 100% speed gain using it.
 
transdrake
Re : Apache optimization tricks (through .htaccess)
08 June 2007 07:35
Anonymous
Sounds nice but let me ask for a few issues thatI've understand correctly or not.

1. That compresses resources (except images) before sending to browser. True?

2. Does every browser support this and can decompress incoming files to view?

Quote:

## do it ONLY if your server as low CPU power


3. That sounds like oposite but, does this compression needs too much of CPU power on server?


Thanks for your interest in advance
 
trex1512
Re : Apache optimization tricks (through .htaccess)
08 June 2007 09:11
Anonymous Quote:
Sounds nice but let me ask for a few issues thatI've understand correctly or not.
1. That compresses resources (except images) before sending to browser. True?
2. Does every browser support this and can decompress incoming files to view?


No simple Yes/No
Answers Here

Quote:
3. That sounds like oposite but, does this compression needs too much of CPU power on server?
Thanks for your interest in advance


A test of the compression levels against a 22k page was done and the results were (in bytes):

off = 22549
1 = 4297
2 = 4279
3 = 4264
4 = 4117
5 = 4097
6 = 4063
7 = 4011
8 = 3998
9 = 3996

The default setting is 6

So if you have a system that is working hard setting the value to a lower number, Danieles example shows 3, it will be kinder on server resources.

Info Here

Looks like Daniele has set ours to 1.
 
legolas558
Re: Re : Apache optimization tricks (through .htaccess)
08 June 2007 16:32
Anonymous Quote:

Quote:
Sounds nice but let me ask for a few issues thatI've understand correctly or not.
1. That compresses resources (except images) before sending to browser. True?
2. Does every browser support this and can decompress incoming files to view?


No simple Yes/No
Answers Here

Which is actually the same URL posted in the original article... smile
Quote:

Looks like Daniele has set ours to 1.

No, it is not set, so it will inherit the default value. I suggest to leave the default value or to modify it if you have a very weak CPU (using 3 for example) or a very strong one (using 7).
 
legolas558
Re: Re : Apache optimization tricks (through .htaccess)
08 June 2007 16:37
Anonymous Quote:

1. That compresses resources (except images) before sending to browser. True?

True (as far as I know).

Quote:

2. Does every browser support this and can decompress incoming files to view?

If the browser does not support it, it is given the uncompressed version of the file. So you should not care about the implementation details; by the way, all modern browsers support compression. More informations on the previously specified URLs.

Quote:

Quote:

## do it ONLY if your server as low CPU power


3. That sounds like oposite but, does this compression needs too much of CPU power on server?

Since the default compression level is 6 (which is a good compromise), you should use a lower compression level only if your server has a very old slow CPU.

About the amount of CPU power: if you do not enable the compression, you will use much more CPU to serve the wasted bandwidth. It is a bottleneck problem...so the rule is: enable compression and use the default compression ratio, unless you know what you are doing. There should be no real concern about CPU power with nowadays technology.
 
transdrake
Anyway,cleared some but...
09 June 2007 08:28
Anonymous A few more question.
Please note that I'm an emty box in web related applications.Thats why please forgive my imcompetence.

1. an htaccess file in "public_html" root with these strings will cause all the apps under that folder to be compressed. True?

2. My server has apache but dont know this module is installed or not but anyway. What is the difference between
Code:

AddOutputFilterByType DEFLATE text/html text/plain text/xml

and
Code:

php_value zlib.output_compression 1

if same thing same performance with same resource usage and also same compatibility (sure not same but closer I mean) so I canuse the PHP one which guarantee works. I'm I True? Or your suggestion

3. So this warning
Quote:

When using one of the above methods, you should turn off the Drake CMS gzip compression (that will not be used).

Means that Drake also have this function? Nor or Yes but not enough like the codes up?

Best regards
 
legolas558
Re : Anyway,cleared some but...
09 June 2007 16:13
Anonymous Quote:

A few more question.
Please note that I'm an emty box in web related applications.Thats why please forgive my imcompetence.

No problem - but we might have hijacked the thread offtopic blush
Quote:

1. an htaccess file in "public_html" root with these strings will cause all the apps under that folder to be compressed. True?

If you have Apache, yes.

Quote:

2. My server has apache but dont know this module is installed or not but anyway. What is the difference between
Code:

AddOutputFilterByType DEFLATE text/html text/plain text/xml

and
Code:

php_value zlib.output_compression 1

if same thing same performance with same resource usage and also same compatibility (sure not same but closer I mean) so I canuse the PHP one which guarantee works. I'm I True? Or your suggestion

The 1st activates Apache's MOD_DEFLATE, the second activates PHP's zlib output compression. Apache's way is better.

Quote:

3. So this warning
Quote:

When using one of the above methods, you should turn off the Drake CMS gzip compression (that will not be used).

Means that Drake also have this function? Nor or Yes but not enough like the codes up?

Drake CMS cannot have the same function of the webserver (Apache) or of a core PHP configuration (zlib.output_compression), but it uses ob_gzhandler().

So in this list the 1st method is the best, and the last the worst. NOTE: "Worst" does not mean that is bad or wrong, just means that it cannot be as performant as the others.

  1. Apache's mod_deflate or any other server-side compression Apache module

  2. set zlib.output_compression to 1, which forces all PHP outputs to be gzip-compressed when the client supports it

  3. enable Drake CMS' gzip compression, which works like zlib.output_compression but will not work if your server as URL rewriters active

About compatibility: you do not have to care about the implementation, these methods ALWAYS work with all browsers.
 
transdrake
Clear
10 June 2007 00:42
Anonymous Perfectly clear. I'll use at least one of them and I think mode deflate will work on my server.
 
legolas558
Re: Clear
10 June 2007 02:55
Anonymous Quote:

Perfectly clear. I'll use at least one of them and I think mode deflate will work on my server.


Use only one of them as using more than one is not correct.
 
Top