Umair_Ahmad_Khan Posted May 21, 2009 Share Posted May 21, 2009 Hi, I have module that uploads an image in db as bytes and shows that image on a button click. Problem is that if i update an image it takes few minutes before it updates. i believe its caching issue but i dont know how to fix it. I am doing something like this HtmlImage AppImg = (HtmlImage)(DetailsView1.FindControl("AppImage")); AppImg.Src = "~/ImageHandler.axd?table=xyz&column=abc&width=157&height=157&pk0=" + Page.Request.QueryString["AppID"]; Any help... ? Thanks in advance. Link to comment Share on other sites More sharing options...
0 Umair_Ahmad_Khan Posted May 21, 2009 Author Share Posted May 21, 2009 i have checked http://localhost:62264/release1/ImageHandler.axd?table= .. ....... and image doesnot update immediately it take time on above URL as well. I have tried these as well Response.Cache.SetNoStore(); Response.Cache.SetNoServerCaching(); Response.Cache.SetCacheability(HttpCacheability.NoCache); but no luck ... Link to comment Share on other sites More sharing options...
0 Antaris Veteran Posted May 21, 2009 Veteran Share Posted May 21, 2009 Hi, Caching is great, but it can also be the bane of many developers! I think most browsers cache images based on the image uri, not the page uri. An easy trick would be to quickly add another querystring item with a random value, e.g.: http://localhost:62264/release1/ImageHandl......&z=43154 Making sure the value is different each page view will ensure the browser fetches the new image each time. Not ideal, but it works. Other (more lower level changes) could include changing the Cache-Control header to no-cache for a specific directory on the webserver itself. Link to comment Share on other sites More sharing options...
0 Umair_Ahmad_Khan Posted May 21, 2009 Author Share Posted May 21, 2009 No luck with adding random string as well ... still not updating. i have tried to add in one browser .. login using another browser and then tried to check image was same and not updated in both browser. so its server side caching.. tried whatever i knew to disable server side caching but no luck Link to comment Share on other sites More sharing options...
Question
Umair_Ahmad_Khan
Hi,
I have module that uploads an image in db as bytes and shows that image on a button click.
Problem is that if i update an image it takes few minutes before it updates. i believe its caching issue but i dont know how to fix it.
I am doing something like this
HtmlImage AppImg = (HtmlImage)(DetailsView1.FindControl("AppImage")); AppImg.Src = "~/ImageHandler.axd?table=xyz&column=abc&width=157&height=157&pk0=" + Page.Request.QueryString["AppID"];Any help... ?
Thanks in advance.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts