Tim Akinbo's Tumblelog RSS

Hi, I'm Tim Akinbo and this is my tumblelog.

Afrigator

My Popularity (by popuri.us)

Archive

Oct
17th
Fri
permalink

Web server tweaking to improve web app performance Pt. 1

If a web developer should aim at making his web application faster, this could mean getting a faster server, using caches, optimizing your code or database schema and so on and so forth.

Having an understanding of how web servers and web browsers work is an important skill to learn. For instance, few know about the cache management processes of web browsers that if factored into your applications, can make it fast.

Web browsers download web pages and other supporting media and cache them if need be. It’s possible to configure your web server to send the necessary headers that will enable web browsers cache data so as to prevent having to make requests for the same content that isn’t changing, over and over again. For instance, quite a number of images that are used in web application interfaces never change over a period of 5 months (or even more). If a web browser requests a particular image, then it shouldn’t make a request again for it as long as it doesn’t change and it can still keep it in its cache. Not only does tweaking your web server help web browsers but also caching proxy servers.

The following snippet can be included in your Apache HTTPD configuration file or .htaccess file.

FileEtag None

<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresByType text/html "access plus 1 day"
	ExpiresByType image/gif "access plus 5 months"
	ExpiresByType image/jpeg "access plus 5 months"
	ExpiresByType text/css "access plus 1 week"
	ExpiresByType application/x-javascript "access plus 1 week"
	ExpiresByType application/javascript "access plus 1 week"
	ExpiresByType image/x-icon "access plus 5 months"
</IfModule>

So what do these options mean?

The FileEtag None option prevents the web server from sending the entity tag for the requested resource. If you do not require that documents be validated (which would be in most cases), then you gain some performance boost in turning the option off.

ExpiresActive On simply turns on the expires module. This module is responsible for sending an additional header to the browser or proxy server informing it of the time the object is expected to expire. This is usually set at a date in the future. Setting this option to a date in the past, automatically expires the resource and the browser will have to request the resource every time. The options as specified by ExpiresByType for the different content types gives the date the object is expected to expire. You can be flexible here but you have to be careful to prevent browsers and proxies from caching objects that are supposed to be served fresh frequently from the web server.

For more information on optimizing your web applications, you can read these articles.

Comments (View)

blog comments powered by Disqus