September 5, 2010, 5:10 pm UTC  

Postings

httpd: accelerate web page performance with mod_expires

More and more goodies are packaged with apache2, allowing one to perform front-end engineering right out of the box. Here are a tip on using mod_expires to maximize the use of browser cache and accelerate performance for repeat visitors.

mod_expires generates Expires and Cache-Control HTTP headers according to user-specified criteria. These HTTP headers instruct the browser about the document’s validity and persistence. As long as the object is valid, no validation requests will be issued, thus minimizing the # of requests & reduce page rendering time. Of course, care should be exercised to prevent object staleness.

On an object where the Expire & Cache-Control headers, the repeat visit results in a validation request (If-Modified-Since):

If-Modified-Since

Here’s a code snippet from httpd.conf on setting embedded objects to expire 1 week from the time the browser first downloads those objects:

ExpiresActive On
ExpiresByType image/jpeg “access plus 1 weeks”
ExpiresByType image/png “access plus 1 weeks”
ExpiresByType image/gif “access plus 1 weeks”
ExpiresByType text/javascript “access plus 1 weeks”
ExpiresByType text/css “access plus 1 weeks”

The resulting response would include the appropriate Expires & Cache-Control header when the object is downloaded on the first time. Thus ensuring that no validation request is issued.

expiry headers

Filed under: httpd — appgirl @ 7:45 pm
Comments (0)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

About

My name is Catherine Liao and you're reading the latest postings of various blogs I follow. You'll notice that the topics tend to center around Cloud Computing, Data Center, Virtualization, Servers, Web Technologies and 24x7 Operations.

These are topics that I'm interested in as I've spent a large chunk of my professional career building, deploying, and maintaining 24x7 application delivery environments. I use the knowledge I've garnered daily in my role as a Technology Solutions Architect for Cisco. I should note that this site is my personal site and does not reflect the views of Cisco.

Feel free to drop me a note if you find this site useful or if you'd like for me to check out your blog. I can be reached at catherine.liao@gmail.com. You can also connect with me via LinkedIn or Twitter.

Looking for less "geeky" content? Check out my travel blog 1-Day Itinerary.

Tweets

Fans

AppGirl on Facebook

See What I'm Uncorking