473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

want to Avoid image cacheing in ASP.NET Pages

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
3 2583
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Clive Backham | last post by:
I tried posting this on comp.infosystems.www.misc, but that group appears to get very little traffic. So now I'm trying here. If there is a more appropriate group, please let me know. I'm...
2
by: Marwin | last post by:
Hi all, I have a database with 40GB of binary objects stored in image columns in two tables. Our database server is also used for another 15 databases. SQL Server caches the image-column,...
5
by: Csaba Gabor | last post by:
Is there any way to determine the pixel height and width of an original image? Specifically, If I have <IMG id=myImg src="pic.jpg" height=200 width=300> can I figure out what the original size...
12
by: Sunny | last post by:
Hi, I need to download some web pages from a web server (most of them are not static html, but .asp pages). The content (I.e. the pure html) in the pages are not changed very often, so I'll...
3
by: Csaba Gabor | last post by:
Not sure of best place for this question... Are there any built in images within the browser that I can assume (particularly IE and FF)? More specifically, I am writing a one file webApp.php...
4
by: Roy | last post by:
Hey all, I just installed 2.0 today. I've been enjoying 1.1 for so long I didn't want to change. :) Anyways, I converted over a web project from 1.1 to 2.0. No problemo. Then I noticed something...
13
by: Viken Karaguesian | last post by:
Hello everyone, Can anyone recommend a good online site to learn PHP? The W3Schools website is quite lacking - leaves much to be desired. I'm sure there are many places, but which ones are good?...
9
by: klausklausenator | last post by:
Hi all, I have a php-generated webpage with images. My problem is: the Internet Explorer cannot calculate the correct image size. Because of this the images are not cached. So everytime a user...
7
by: Inny | last post by:
Hello again, Im using the code below in a child page (popup), the images are called from the parent page. When the changer is running, the child page goes white between images. I realise this is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.