emer.kurbegovic
8/8/2006 7:30:00 AM
I've got a custom built HttpHandler that I use to display the image
blobs from the db. I am getting the image straight from the db, resize
it if neccessary, cache it and display on the web page. The problem I
am having is that, eventhough the images are being cached in my temp
internet folder they are reloaded from the db on each request.
Actually, when i rebuild the complete solution the images get cached
and they are also pulled from the cache on each call. but if i use my
web app for few minutes, all of the sudden, i get few images here and
there that are not being pulled from the cache. The more I use my web
app the more pics quit being loaded from the cache.
i have no clue what am i doing wrong here... Is this a bug and if so
how do I fix it?
Why are my images being saved to cache, then being pulled from cache
and then just simply quit being pulled from cache?
Images are loaded like this:
<img border="0"
src="image.axd?type=Cat1&id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&width=150"
/>
I cache the image like this in the HttpHandler:
context.Cache.Insert(cacheKey, picInfo);
context.Response.Clear();
context.Response.Cache.SetExpires(DateTime.Now.AddMinutes(expireInMinutes));
context.Response.Cache.SetCacheability(httpCacheability);
context.Response.Cache.SetValidUntilExpires(true);
context.Response.Cache.SetLastModified(DateTime.Now);
context.Response.Cache.SetMaxAge(new TimeSpan(0, expireInMinutes, 0));
Then I output the image like this:
context.Response.ContentType = picInfo.ContentType;
context.Response.BufferOutput = false;
context.Response.OutputStream.Write(picInfo.PicBytes, 0,
picInfo.PicBytes.Length);