i currently do not cache on the server at all. i wanted to make sure
caching properly in the client's browser first. i am aware that caching
on client's cache settings. the things is that, even though everything
i am going to setup a file cache provider for the images on the server.
from the browser cache. does it matter that the images are cached like
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/blogs/alvin > -------------------------------------------------------
>
>
> <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/blogs/alvin > >> -------------------------------------------------------
> >>
> >>
> >> <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&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);
> >> >
> >