By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

want to Avoid image cacheing in ASP.NET Pages

P: n/a
I am currently working on my personl website a completely DB driven
web application. in that i ve updating the images thru my admin
panel .. but i am getting the old images not the update one when see
the pages in the front . when i explicitly right click and select
refresh button or hit F5 ,then my pages are loaded with new images..
why this kind of effect is happening. how to avoid the caching of
images in both the server side(page cache) and client side? can anyone
help me to solve this problem. i am accessing the admin module and the
pages in a same computer.

Regards.
Visu

Jan 30 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The easiest (and certainly not the only) way to ensure that the browser does
not cache images is to suffix the image url with a unique querystring item,
like so:

"http://mysite/images/image001.jpg?id="+DateTime.Now.Ticks.ToString()

Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"visu" wrote:
I am currently working on my personl website a completely DB driven
web application. in that i ve updating the images thru my admin
panel .. but i am getting the old images not the update one when see
the pages in the front . when i explicitly right click and select
refresh button or hit F5 ,then my pages are loaded with new images..
why this kind of effect is happening. how to avoid the caching of
images in both the server side(page cache) and client side? can anyone
help me to solve this problem. i am accessing the admin module and the
pages in a same computer.

Regards.
Visu

Jan 30 '07 #2

P: n/a
On Jan 30, 5:05 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
The easiest (and certainly not the only) way to ensure that the browser does
not cache images is to suffix the image url with a unique querystring item,
like so:

"http://mysite/images/image001.jpg?id="+DateTime.Now.Ticks.ToString()

Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"visu" wrote:
I am currently working on my personl website a completely DB driven
web application. in that i ve updating the images thru my admin
panel .. but i am getting the old images not the update one when see
the pages in the front . when i explicitly right click and select
refresh button or hit F5 ,then my pages are loaded with new images..
why this kind of effect is happening. how to avoid the caching of
images in both the server side(page cache) and client side? can anyone
help me to solve this problem. i am accessing the admin module and the
pages in a same computer.
Regards.
Visu- Hide quoted text -

- Show quoted text -
thats great idea but now only i ve noticed that all my pages are get
cached in the browser.. how to avoid caching in the browser.. i ve
tried meta tags and setting header parameter to escape caching of
pages.. but no use .. give me handy solution to this problem.

Regards
visu

Jan 30 '07 #3

P: n/a
Thus wrote Visu,
I am currently working on my personl website a completely DB driven
web application. in that i ve updating the images thru my admin panel
.. but i am getting the old images not the update one when see the
pages in the front . when i explicitly right click and select
refresh button or hit F5 ,then my pages are loaded with new images..
why this kind of effect is happening. how to avoid the caching of
images in both the server side(page cache) and client side? can anyone
help me to solve this problem. i am accessing the admin module and the
pages in a same computer.
1) If you serve your images as static content through IIS:
Put all images in a common folder and set a HTTP Cache-Control header for
this folder in IIS manager, e.g.
Cache-Control: no-cache (-never use a cached copy without revalidation)
or
Cache-Control: max-age=43200 (-allow public caching for 12 hours [43200
seconds] at most)

2) If you serve your images as dynamic content through ASP.NET, e.g.
Response.Cache.SetCacheability(HttpCacheability.No Cache);
or
Response.Cache.SetMaxAge(TimeSpan.FromHours(12.0)) ;

Note that unless you're updating your images at an astounding pace, marking
them non-cacheable is hardly advisable ;-)

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.