SERVER - Improve Server Performances With Headers And GZIP

Tags And Keywordscache, gzip, headers, htaccess, performance, server


Subject: 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.

Subject: Re: SERVER - Improve Server Performances With Headers And GZIP
good one MG

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

Subject: Re: SERVER - Improve Server Performances With Headers And GZIP
Thanks MG, I will test it

Profile PM  
Subject: Re: SERVER - Improve Server Performances With Headers And GZIP
Very nice. Thank you, MG. I noticed a difference right away.

Profile PM  

Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.8525s (PHP: 2% SQL: 98%)
SQL queries: 16 - Debug Off - GZIP Enabled