Currently we're sending thousands of e-mails every day to our customers. An e-mail contains an image url with a specific Message ID. When the user downloads that image, I mark that message as opened in the database. For example:
http://cdn.mydomain.com/companylogos/{guid}.png?h=100&w=100&messageid=123
At this moment, every image request requires me to get the byte[ ] of the image from cache. Resize it. And Return it. This all takes place in a httphandler.
I would like to take the advantage of ImageResizer.net and the Disk Cache plugin. However, I still need to get the MessageId-querystring parameter. So I'm thinking about this solution.
Extending HttpModule
public class CustomInterceptModule : InterceptModule
{
protected override void HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf)
{
var messageIdParam = context.Request.QueryString["messageId"];
int messageId;
if (!string.IsNullOrWhiteSpace(messageIdParam) && int.TryParse(messageIdParam, out messageId))
{
// Do something with the ID here
}
base.HandleRequest(context, ra, vf);
}
}
Does this method still creates high performance, disk cached, results? Or am I interrupting this because I'm extending the HttpModule and I'm adding my own logic in there.
If your goal is to increase performance and/or reduce the work you server needs to do, I would suggest that you should not use a full-size image for tracking purposes, but instead use an invisible 1x1.png image to track whether or not a message was opened, and simply use a standard img url that everybody shares (that can be distributed on a CDN and/or cached) for the image that people actually see.