[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

Problems Caching dynamic images in the HttpHandler...

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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);

8 Answers

emer.kurbegovic

8/9/2006 9:35:00 PM

0

i can't believe nobody knows what i am talking about...

@gmail.com wrote:
> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);

Alvin Bruney [ASP.NET MVP]

8/12/2006 10:21:00 PM

0

>i can't believe nobody knows what i am talking about...
We do, it's probably not that interesting that somebody would actually take
a look.

You haven't shown the code that tests the cache. If you don't have it, you
need to add it in there. The problem you are most likely running into is
cache scavenging. The run-time makes no guarantee that what you put in cache
will be available when you need it. Your code needs to take that into
account. By testing the cache for null and loading it as appropriate, the
problem will be reduced. However, you'll still run into it under heavy load
because of concurrent accesses when the cache is flushed.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/b...
-------------------------------------------------------


<emer.kurbegovic@gmail.com> wrote in message
news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
>i can't believe nobody knows what i am talking about...
>
> @gmail.com wrote:
>> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
>


emer.kurbegovic

8/14/2006 4:32:00 PM

0

Alvin,
thanks for replying...

basically i am trying to cache the dynamic images in the client's
browser cache so that they are not requested from the db on every
request. the pics are currently in the db and i would like to keep them
there (i don't want to save them on a separate server). i thought the
way i was doing this would accomplish that. i don't really need the
pics to be saved in the server's cache, just the client's browser
cache.


thank you,
emer


Alvin Bruney [MVP] wrote:
> >i can't believe nobody knows what i am talking about...
> We do, it's probably not that interesting that somebody would actually take
> a look.
>
> You haven't shown the code that tests the cache. If you don't have it, you
> need to add it in there. The problem you are most likely running into is
> cache scavenging. The run-time makes no guarantee that what you put in cache
> will be available when you need it. Your code needs to take that into
> account. By testing the cache for null and loading it as appropriate, the
> problem will be reduced. However, you'll still run into it under heavy load
> because of concurrent accesses when the cache is flushed.
>
> --
> ________________________
> Warm regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> Professional VSTO.NET - Wrox/Wiley
> The O.W.C. Black Book with .NET
> www.lulu.com/owc, Amazon
> Blog: http://www.msmvps.com/b...
> -------------------------------------------------------
>
>
> <emer.kurbegovic@gmail.com> wrote in message
> news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
> >i can't believe nobody knows what i am talking about...
> >
> > @gmail.com wrote:
> >> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
> >

Alvin Bruney [ASP.NET MVP]

8/15/2006 12:49:00 AM

0

Ok, well that's the problem. Since the cache is on the client, different
clients connecting to the application will not have cached images initially.
Therefore your application will keep servicing requests for the same images
over and increasing the load on the db unnecessarily. Granted, once a client
receives the image, they likely will read from cache on the subsequent
visit, however as you can see, this heralds poor performance for new
clients, or clients with disable client caches (for one reason or the
other), or clients who run multiple browsers etc etc.

The better approach is to cache on the server, that way no matter who
connects or what the state of the browser is, they always read from cache
and pull from the db exactly once irrespective of load, browser usage etc
etc. (well not really exactly once because the cache can flush but you get
my drift)

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/b...
-------------------------------------------------------


<emer.kurbegovic@gmail.com> wrote in message
news:1155573093.840801.249790@m73g2000cwd.googlegroups.com...
> Alvin,
> thanks for replying...
>
> basically i am trying to cache the dynamic images in the client's
> browser cache so that they are not requested from the db on every
> request. the pics are currently in the db and i would like to keep them
> there (i don't want to save them on a separate server). i thought the
> way i was doing this would accomplish that. i don't really need the
> pics to be saved in the server's cache, just the client's browser
> cache.
>
>
> thank you,
> emer
>
>
> Alvin Bruney [MVP] wrote:
>> >i can't believe nobody knows what i am talking about...
>> We do, it's probably not that interesting that somebody would actually
>> take
>> a look.
>>
>> You haven't shown the code that tests the cache. If you don't have it,
>> you
>> need to add it in there. The problem you are most likely running into is
>> cache scavenging. The run-time makes no guarantee that what you put in
>> cache
>> will be available when you need it. Your code needs to take that into
>> account. By testing the cache for null and loading it as appropriate, the
>> problem will be reduced. However, you'll still run into it under heavy
>> load
>> because of concurrent accesses when the cache is flushed.
>>
>> --
>> ________________________
>> Warm regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> Professional VSTO.NET - Wrox/Wiley
>> The O.W.C. Black Book with .NET
>> www.lulu.com/owc, Amazon
>> Blog: http://www.msmvps.com/b...
>> -------------------------------------------------------
>>
>>
>> <emer.kurbegovic@gmail.com> wrote in message
>> news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
>> >i can't believe nobody knows what i am talking about...
>> >
>> > @gmail.com wrote:
>> >> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
>> >
>


Freddie

8/15/2006 12:40:00 PM

0

do u use JS on the browser to preload images?

emer.kurbegovic@gmail.com wrote:
> Alvin,
> thanks for replying...
>
> basically i am trying to cache the dynamic images in the client's
> browser cache so that they are not requested from the db on every
> request. the pics are currently in the db and i would like to keep them
> there (i don't want to save them on a separate server). i thought the
> way i was doing this would accomplish that. i don't really need the
> pics to be saved in the server's cache, just the client's browser
> cache.
>
>
> thank you,
> emer
>
>
> Alvin Bruney [MVP] wrote:
>
>>>i can't believe nobody knows what i am talking about...
>>
>>We do, it's probably not that interesting that somebody would actually take
>>a look.
>>
>>You haven't shown the code that tests the cache. If you don't have it, you
>>need to add it in there. The problem you are most likely running into is
>>cache scavenging. The run-time makes no guarantee that what you put in cache
>>will be available when you need it. Your code needs to take that into
>>account. By testing the cache for null and loading it as appropriate, the
>>problem will be reduced. However, you'll still run into it under heavy load
>>because of concurrent accesses when the cache is flushed.
>>
>>--
>>________________________
>>Warm regards,
>>Alvin Bruney [MVP ASP.NET]
>>
>>[Shameless Author plug]
>>Professional VSTO.NET - Wrox/Wiley
>>The O.W.C. Black Book with .NET
>>www.lulu.com/owc, Amazon
>>Blog: http://www.msmvps.com/b...
>>-------------------------------------------------------
>>
>>
>><emer.kurbegovic@gmail.com> wrote in message
>>news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
>>
>>>i can't believe nobody knows what i am talking about...
>>>
>>>@gmail.com wrote:
>>>
>>>>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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
>>>
>

emer.kurbegovic

8/15/2006 4:16:00 PM

0

i currently do not cache on the server at all. i wanted to make sure
the pics are
caching properly in the client's browser first. i am aware that caching
in the browser depends
on client's cache settings. the things is that, even though everything
is setup correctly on my own client,
the images quit loading from the local browser cache folder after few
minutes.

i am going to setup a file cache provider for the images on the server.
right now i am trying to figure out why the images quit being loaded
from the browser cache. does it matter that the images are cached like
this: "image.axd?type=cat1&id=343433343&width=150".

Does querystring attached to the image has anything to do with this
behavior?

thank you

Alvin Bruney [MVP] wrote:
> Ok, well that's the problem. Since the cache is on the client, different
> clients connecting to the application will not have cached images initially.
> Therefore your application will keep servicing requests for the same images
> over and increasing the load on the db unnecessarily. Granted, once a client
> receives the image, they likely will read from cache on the subsequent
> visit, however as you can see, this heralds poor performance for new
> clients, or clients with disable client caches (for one reason or the
> other), or clients who run multiple browsers etc etc.
>
> The better approach is to cache on the server, that way no matter who
> connects or what the state of the browser is, they always read from cache
> and pull from the db exactly once irrespective of load, browser usage etc
> etc. (well not really exactly once because the cache can flush but you get
> my drift)
>
> --
> ________________________
> Warm regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> Professional VSTO.NET - Wrox/Wiley
> The O.W.C. Black Book with .NET
> www.lulu.com/owc, Amazon
> Blog: http://www.msmvps.com/b...
> -------------------------------------------------------
>
>
> <emer.kurbegovic@gmail.com> wrote in message
> news:1155573093.840801.249790@m73g2000cwd.googlegroups.com...
> > Alvin,
> > thanks for replying...
> >
> > basically i am trying to cache the dynamic images in the client's
> > browser cache so that they are not requested from the db on every
> > request. the pics are currently in the db and i would like to keep them
> > there (i don't want to save them on a separate server). i thought the
> > way i was doing this would accomplish that. i don't really need the
> > pics to be saved in the server's cache, just the client's browser
> > cache.
> >
> >
> > thank you,
> > emer
> >
> >
> > Alvin Bruney [MVP] wrote:
> >> >i can't believe nobody knows what i am talking about...
> >> We do, it's probably not that interesting that somebody would actually
> >> take
> >> a look.
> >>
> >> You haven't shown the code that tests the cache. If you don't have it,
> >> you
> >> need to add it in there. The problem you are most likely running into is
> >> cache scavenging. The run-time makes no guarantee that what you put in
> >> cache
> >> will be available when you need it. Your code needs to take that into
> >> account. By testing the cache for null and loading it as appropriate, the
> >> problem will be reduced. However, you'll still run into it under heavy
> >> load
> >> because of concurrent accesses when the cache is flushed.
> >>
> >> --
> >> ________________________
> >> Warm regards,
> >> Alvin Bruney [MVP ASP.NET]
> >>
> >> [Shameless Author plug]
> >> Professional VSTO.NET - Wrox/Wiley
> >> The O.W.C. Black Book with .NET
> >> www.lulu.com/owc, Amazon
> >> Blog: http://www.msmvps.com/b...
> >> -------------------------------------------------------
> >>
> >>
> >> <emer.kurbegovic@gmail.com> wrote in message
> >> news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
> >> >i can't believe nobody knows what i am talking about...
> >> >
> >> > @gmail.com wrote:
> >> >> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
> >> >
> >

emer.kurbegovic

8/15/2006 4:16:00 PM

0

no, i don't use js on the browser to preload images.
Freddie wrote:
> do u use JS on the browser to preload images?
>
> emer.kurbegovic@gmail.com wrote:
> > Alvin,
> > thanks for replying...
> >
> > basically i am trying to cache the dynamic images in the client's
> > browser cache so that they are not requested from the db on every
> > request. the pics are currently in the db and i would like to keep them
> > there (i don't want to save them on a separate server). i thought the
> > way i was doing this would accomplish that. i don't really need the
> > pics to be saved in the server's cache, just the client's browser
> > cache.
> >
> >
> > thank you,
> > emer
> >
> >
> > Alvin Bruney [MVP] wrote:
> >
> >>>i can't believe nobody knows what i am talking about...
> >>
> >>We do, it's probably not that interesting that somebody would actually take
> >>a look.
> >>
> >>You haven't shown the code that tests the cache. If you don't have it, you
> >>need to add it in there. The problem you are most likely running into is
> >>cache scavenging. The run-time makes no guarantee that what you put in cache
> >>will be available when you need it. Your code needs to take that into
> >>account. By testing the cache for null and loading it as appropriate, the
> >>problem will be reduced. However, you'll still run into it under heavy load
> >>because of concurrent accesses when the cache is flushed.
> >>
> >>--
> >>________________________
> >>Warm regards,
> >>Alvin Bruney [MVP ASP.NET]
> >>
> >>[Shameless Author plug]
> >>Professional VSTO.NET - Wrox/Wiley
> >>The O.W.C. Black Book with .NET
> >>www.lulu.com/owc, Amazon
> >>Blog: http://www.msmvps.com/b...
> >>-------------------------------------------------------
> >>
> >>
> >><emer.kurbegovic@gmail.com> wrote in message
> >>news:1155159270.267187.165780@m79g2000cwm.googlegroups.com...
> >>
> >>>i can't believe nobody knows what i am talking about...
> >>>
> >>>@gmail.com wrote:
> >>>
> >>>>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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
> >>>
> >

liuchenzhong

9/8/2006 7:43:00 PM

0

There are number of ways to cache your images

>> Put your image control on to a user control and do partial caching on the
>> control. set the outputcachelocation to "downstream". The output cache
>> can be stored in any HTTP 1.1 cache-capable devices other than the origin
>> server. This includes proxy servers and the client that made the request.

>> cache your images on the file systems of the presentation layer if there
>> is sufficient resource available on the layer.

>> write content expiry settings into the http header when returns your
>> image.

Hope this helps

Byron



<DIV>&lt;emer.kurbegovic@gmail.com&gt; wrote in message
news:1155022192.646726.215630@h48g2000cwc.googlegroups.com...</DIV>> 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&amp;id=e7810e9f-2abe-4a54-9b58-d82cd2b8fa6d&amp;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);
>