877-8-GO 4 IAM
4  6  4  4  2  6

home > about us > Featured Geek

Featured Geek

Reliam's most important asset is our talented team of Internet Application Engineers. Every month exceptional individuals from our team are featured. They discuss issues or solutions that are dear to the featured geeks heart at the present moment. These issues just might be dear to your heart too.

The Stages of Caching

By Christopher Evans, Internet Application Engineer

July 26, 2010 - We here at Reliam are in the business of scaling web applications. What does this mean. We work closely with developers on a constant basis to optimize websites and improve the page load times. One  such method of increasing the load time of assets and increasing overall website speed is caching; especially with a CDN.  User provided images are the easy part.  Next to address caching of JavaScript and CSS... Finally, caching of the html, including support for dynamic portions. A perfect example of these in action is the hosted blogging platform, http://www.tumblr.com, which utilizes many of these caching optimization strategies.

Images

When a user uploads an image, the programmer gets to decide what to name the image, and where it should be saved.  This allows for the server to specify that the image will never change, allowing caching both at the CDN, and in the users browser.  If the image is a profile picture, and the user changes it, there is no problem.  It just gets saved as a different URL, and can be cached forever too.  This can also apply to admin users, and the site's CMS (Content Management System).  The banners that get uploaded can have the same methods applied to them. Tumblr achieves this level of caching by using Edgecast in front of Amazon s3.

JavaScript and CSS

A less common method of caching in our experience is the CSS and JavaScript files that help the website run.  Unless the website knows when these files change, they can be cached only for a short while, or not at all.  However, if these assets can be served from a CDN, then the user will be able to download them quickly, and the CDN will only have to check to see if the file was modified.  It seems that tumblr does part of this by versioning the directory the JavaScript is placed in, but it does not set the expires headers like it does for the images (expires headers tell the browser how long the asset doesn’t need to be requested for). This may mean that they just keep track of the JavaScript for each tumblr site, and thus do not use expires headers.

HTML

Getting the actual HTML for a site to be cached can be the most difficult part.  If there is a user login, you typically cannot use full page caching.  One of our clients had a nice method for dealing with this problem.  If the visitor wasn't a logged in user, and if there was a recent cache of the page being visited, it would serve that, instead of talking to the database, and recreating the page.  If there wasn't a cached copy, it would create the page, send it to the user, but also cache it for the next visitor.

An additional step in caching, if it's valid for your site, is the custom links for logged in users.  You can set-up the entire page to cache, and have JavaScript detect which user is logged in.  The JavaScript can change from a login link, to links to the users profile page, and a link to logout.  The JavaScript just needs to read the users cookie.

In a similar manner, JavaScript can be used to update the parts of the page that change the most often, such as twitter posts, discussion updates, and recently updated photos.  The full page cache can have a recent copy of all of these things, but JavaScript can be used to talk to the website and retrieves just those pieces.  These pieces can even be pulled from the CDN, letting updates load that much quicker, and reducing the load on the web servers.

The last step in caching takes the most effort on the programmer’s part.  I think this is where website frameworks can lend a hand.  Ruby on Rails has the concept of partials; these little bits of pages that are common across many views, perfect for the list of latest tweets, or latest uploads.  If a tag can be added to each partial, saying how often to update, and where to go for that update, this last part can be a snap.  There is a theme for Tumblr that seems to do the same thing, loading a spinning graphic while the rest of the page loads, http://scaffold.tumblr.com/. Caching partials can even be used if there are some parts of the page that can't be cached.  Have the partial return a blank section, along with instructions on where to get the proper content.  This will allow the app tier of the website to render the html once, and have it served from the CDN, allowing for much quicker load times.  One example of this is comments, such as the system provided by http://disqus.com/.

In conclusion, caching is used to provide a fantastic user experience and increase website functionality, don’t leave home without it.


Archives

Tuning LAMP Stack

By Chris Harshman, Internet Application Engineer

January 28, 2010 - One of the most critical aspects of Linux, Apache, MySQL, PHP[1] application management is tuning the software components that make up this "stack" of software.  Without proper benchmarking and tuning, your application could slow to a crawl under load, being bogged down by excessive swapping or lengthy database queries -- or worse, it could fail completely. Read more

 

Automation is the Cloud

By Brandon Burton, Internet Application Engineer

October 6, 2009 - There has been a lot of buzz, press coverage, and product offerings over the last year that all have something about "The Cloud" in them. I think it is important that as technologists and sys admins, we do what we can to bring clarity to what "The Cloud" is and how it affects and benefits you. This is my take on what "The Cloud" is and my attempt to bring some clarity to the discussion. Read more

 

Using Bash to Glue UNIX

By Nathan Rich, Internet Application Engineer

August 2, 2009 - Much like Perl is the glue language for programmers, BASH scripting is the glue language for UNIX and Linux operating systems themselves. When I was learning linux concepts I started by mastering BASH. I purchased the book, “Learning the BASH Shell” and went to work studying and applying the information within. I love working with BASH because the more you learn it the more you learn about UNIX and Linux's GNU tools. Thus by simply studying and applying one relatively easy language, you learn all of the common elements of interacting with UNIX and Linux. Read more

 

PARTNERS
Partners Net2Ez EdgeCast Content Delivery Network MicroSoft Certified Partner Fortinet Dell Brocade