What makes for the best performance?

Started by sukishan, Aug 23, 2009, 12:09 AM

previous topic - next topic
Go Down

sukishan

What makes for the best performance?
For static components such as CSS, JavaScript, and images that seldom change, it's good to use Expires cache control headers with a date in the far future--not too far, though! According to the HTTP 1.1 protocol, an HTTP server should not send an Expires header that's greater than one year into the future.

Of course, these static components might be updated from time to time--for example, if you make some CSS fixes or upload some new images. One way to make sure the browser fetches the updated resources straight away is to add the version number of the static components as if it were a GET variable. Simply put a version number at the end of the item's URL in the markup.

Here's an example. Suppose a document's HTML markup references version 1 of a style sheet, which we'll call special.css. We could reference special.css as follows in the HTML document:

<head>
   <link href="special.css?v=1" rel="stylesheet" type="text/css" />
</head>

Later, when the design changes, the corresponding HTML markup could be:

<head>
   <link href="special.css?v=2" rel="stylesheet" type="text/css" />
</head>

The browser will see the new GET variable, treat the file as if it were new, and download the fresh style sheet.

For content that changes frequently, we should ensure the browser makes that conditional request so that it can get the freshest content--but only when that content has changed. To make this work, we should include both the Last Modified and Cache-Control: max-age=0, must-revalidate headers in the server response. That way, the browser will always make a conditional request when the component is referenced in the HTML markup. If the component is unaltered, the server can return a response with a 304 Not Modified status to indicate that the content is unchanged, instead of sending the full response.
A good beginning makes a good ending

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Designing Chennai | GinGly :: Build your Personal Website | CineBuzz :: Cinema News | My Kids Diary :: Gift your Kids Memories :: Book Website @ 349 Rs monthly
Copyright 2005 - 2021 :: IT Acumens :: All Rights Reserved. :: XML Sitemap
ITAcumens Discussion Forum with 2 lakhs post running for 15 years - Powered by IT Acumens Pro Dedicated Server

My Kids Diary