Thursday, September 30, 2010

How to improve your site performance

30 seconds visitor needs to decide if he likes your web site. Reducing page load time could certainly improve your bounce rate statistics. These tips will help you improve your client side performance.

1) Reduce number of request: When page is loading all files referenced on this page have being downloaded, which means for each image, css and js file request is created. If you have 20 images on page 20 parallel request are fired on each load. Ways to reduce request number:
  • Combine files - try to merge css and script files.
  • Use CSS sprites - as was said above each image is request on server, use CSS sprites where it is possible.
  • Remove unnecessary counters and scripts - one counter may be enough to your site. remember each of them taking time on load.
2) Move static content to another host: Images, scripts and flash objects should be located on different host to reduce request load on main server.

3) Use browser caching for static content: Set expiration date for each static image, this will cache images on user's browser cache. This is perfect for returning visitor experience.

IIS 7.0 example:

<staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00"/> < staticContent>

This will add relative expiration date to static content, in this case 7 days.

4) Minify CSS and Javascript files: If you use jquery or other script library use its minified version. In addition
it better reference these libs via CDN networks. Minify your css files with variety of css compression tools.


5) Use Google Page Speed utility: This Firefox addon will help you to improve some aspects of your site's performance.

Monday, May 11, 2009

Feedbacks for your web site

So you have a site and you probably would like to know what visitors think about it. Visitor's opinion is very important especially at the beginning. Certainly you have no time for developing your own feedback solution. I believe they are many but I found this one that is pretty nice.

There few service packages you may choose one fits your needs. I use free package I do not need more than that.

Reporting is good you can view feedbacks and grades by category, categories are pre-defined but its covers whole functionality I think.

Setup is easy - 2 javascript and you are ready to go.

I liked that user on the site is been asked to post a feedback, it pretty annoying when you are working with the site but from the other hand good for business.

Tuesday, May 6, 2008

ASP.NET: Losing session state while running application in iframe

If your application is inside iframe with parent belongs to another domain - cookies will not work for some very common configurations for example IE 6/7 with privacy set to medium. If cookies don't work - session won't work.

For solution you need to add P3P header to your appliction's request:


protected void Application_BeginRequest(Object sender, EventArgs e)
{
//
// add p3p header
//
HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");
}

sending url parameters in russian

recently i worked on project that used to send url parameters in russian language via query string. parameters are combined in url using javascript function that opens a new window. in ff, opera and safari it worked great, but in ie 7 parameters wes represented as "????" strings. Seems that http protocol not work with unicode string in url.

To solve that problem add a built in javascript function encodeURIComponent on a client side and Server.UrlDecode on your server side

Thursday, February 28, 2008

Handling not existing element with lambda expressions

To return not existing element from lambda expression use .SinleOrDefault() method instead of .Single(). In this case it returns null insdead of exception.

Wednesday, October 31, 2007

Changing database collation on SQL 2005

Encountered with difficulties to change db collation. I ran tsql statement

ALTER DATABASE test
COLLATE SQL_Latin1_General_CP1_CI_AS


Gived me exception:
"The database could not be exclusively locked to perform the operation"

In order to change collation set database to single user mode and than execute change query.


ALTER DATABASE test SET SINGLE_USER WITH ROLLBACK IMMEDIATE

To return db to multi user mode:

ALTER DATABASE test SET MULTI_USER WITH ROLLBACK IMMEDIATE