Sunday, July 19, 2009

Ever got spammed? Ever used CAPTCHA?

We all know what spam is and might have already discussed lot about it. But, did you ever face spam which directly impacted your revenue and user experience? I have experienced that. I used to work for an online portal in which users can post their comments, new topics, etc. One fine day series of spam attacks occurred and the site became literally unusable and had to be taken offline. We had to cleanup all that mess and to prevent such attacks, introduced a captcha in all the places where user submissions are taken.


The topic that I want to discuss here is the effect of captcha on the site. Is it all positive or does it have some negative effect as well? This article explains in detail that users don't always like captcha and it drives away considerable number of genuine users.

Fortunately, it also points to a simple solution - Honeypot CAPTCHA technique. Phil Haack suggests use of a blank hidden field (using CSS) which will be ignored by real users but would be filled by the bots. I liked this idea and would surely use it in future.

Did you have any experience with Spam Attacks and Captchas? Share your suggestions/experiences by posting comments..

Wednesday, July 15, 2009

Ever Copied Video/Movie Fie from a Bad/Scratched CD/DVD?

I had to copy an important and large video from an old CD and ran in to errors wasting lot of time yesterday. I tried doing the copy through windows which took lot of time and ended abruptly with a 'Cyclic Redundancy Check Error'. Being a smart guy, I tried it the old DOS way. But still no luck! It also ended in same CRC error after taking lot of time.

Obviously, there is something wrong with my old cd data and part of it might be bad. But why should I loose all my data just because of few bad sectors? I kept wondering why the copy functionality in windows is not smart enough to ignore those damaged bytes and copy the rest of the file. Specially with video files, it won't hurt even if we miss few bytes here and there. I knew there will be others who think on the similar lines and googled for a solution. I got lots of links and info. I carefully selected an application and it did the trick for me magically.


The tool is 'Copy It Anyway'. And I got it from here. After installing it, all I had to do is give it the source and destination details and it did the rest. Copying was faster except for the sound alerts when it hit a bad byte. After copying the entire file, I played the video and to my surprise, I don't notice any issues with it except for few damaged frames. This tool was a life saver for me.

Do you have any experience like this? Do share your views by posting comments.

Sunday, July 12, 2009

ASP.Net - Caching static files (images, css, js, etc. ) to improve performance

Recently we had a need for performance improvement in our large web application. With one simple solution, we could achieve great performance improvement. We just implemented static file caching. We cached all static files like images in our web application which resulted in less calls to the server with each request and improving performance in many folds.

To understand the impact of static files with your application, you might want to use a utility like fiddler or microsoft network monitor. Hit your page and see what files are actually request and transmitted from server each time. In our case, we had these logos, menu images, css files, common js files etc. received each time a page request is made. After logging these calls for a simple use case, we could see how this is hampering the performance.

There is a nice article explaining different ways to achieve static file caching in ASP.Net. We used http module to listen to the requests and append/edit some headers to do the caching part. Without touching thousands of pages in the app and without even touching the IIS (which would be difficult to do for 1000+ existing customers hosting it in their network) we could improve the performance considerably. If you are looking for the actual code that made it work, you might want to dig into the HttpContext.Response.Cache class. You might find the following methods useful:

SetValidUntilExpires(true);
SetCacheability(HttpCacheability.ServerAndPrivate);
SetMaxAge(TimeSpan.FromMinutes(expirationTime));
SetExpires(DateTime.UtcNow.AddMinutes(expirationTime));

Did you find this tip useful? Or do you know of any other tips to improve performance of ASP.Net applications? Do share your views by posting comments.