Icy Phoenix

     
 

SERVER - Improve Server Performances With Headers And GZIP

SERVER - Improve Server Performances With Headers And GZIP

Article
Reply with quote    Download Post  
Post SERVER - Improve Server Performances With Headers And GZIP 
 
Hi,
I have recently found this very interesting code to be added to templates/.htaccess to speed up page loading.

In particular this first part is for sending text files using GZIP to save bandwidth and speed up script and stylesheets loading:

Code: [Download] [Hide] [Select]
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>




This part is maybe more useful, because let's you add EXPIRES for some particular files (JS, CSS, templates images) allowing browsers to keep in cache (if they are not yet doing that) some common files which are rarely changed:

Code: [Download] [Hide] [Select]
<IfModule mod_expires.c>
    # Once per day I think is enough for most cases...
    ExpiresActive on
    ExpiresByType image/gif "access plus 1 day"
    ExpiresByType image/jpeg "access plus 1 day"
    ExpiresByType image/jpg "access plus 1 day"
    ExpiresByType image/png "access plus 1 day"
    ExpiresByType text/plain "access plus 1 day"
    #ExpiresByType text/html "access plus 15 minutes"
    #ExpiresByType text/tpl "access plus 15 minutes"
    ExpiresByType text/css "access plus 1 day"
    ExpiresByType text/javascript "access plus 1 day"
    ExpiresByType application/x-shockwave-flash "access plus 1 day"
</IfModule>



You can add both of these code to templates/.htaccess (just paste below the other code) or use only what you need / like... I personally use both of them here, and I think speed has improved.

Let me know if you have any questions about that.


P.S.: of course these pieces of codes will only work on thse servers with the right APACHE MODULES loaded.



 
Mighty Gorgon - View user's profile Send private message  
Mighty Gorgon [ Wed 02 Mar, 2011 15:57 ]
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us


SERVER - Improve Server Performances With Headers And GZIP

Comments
Reply with quote    Download Post  
Post Re: SERVER - Improve Server Performances With Headers And GZIP 
 
good one MG

personaly, been using js compression and css compression for a while already.



 
spydie - View user's profile Send private message  
spydie [ Wed 02 Mar, 2011 16:01 ]
Reply with quote    Download Post  
Post Re: SERVER - Improve Server Performances With Headers And GZIP 
 
Thanks MG, I will test it



 
TheSteffen - View user's profile Send private message  
TheSteffen [ Wed 02 Mar, 2011 22:50 ]
Reply with quote    Download Post  
Post Re: SERVER - Improve Server Performances With Headers And GZIP 
 
Very nice. Thank you, MG. I noticed a difference right away.



 
nothere - View user's profile Send private message  
nothere [ Sun 24 Apr, 2011 22:10 ]
Display posts from previous:    

HideWas this topic useful?

Post new topic  Reply to topic  Page 1 of 1
 
 




 


 

  cron