473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Asp.net 2.0 caching and images

Hi,

I'm having a strange problem:

I have a product.aspx page where the admin can change product
properties, including the JPEG. The JPEG will always have the same
name: eg. 120.jpg and in the same location.

1) Admin visits page and browses to images/myimage.jpg
2) Application takes myimage.jpg and creates a modified copy in
myapp/img and calls it 120.jpg.
3) image path in database changes to myapp/img/120.jpg
3) Admin leaves page
4) Admin revisits page (in same session) and picks a different image,
which replaces the old one but retains the name 120.jpg.
5) Admin leaves and comes back one more time. OLD IMAGE IS STILL
DISPLAYED (from step 2). Even though image is changed on hard drive.

obviously, IE is caching the image and going back to it on subsequent
visits in same session. I tried using the No-Cache directive. I also
added a ?t=<random> to the page parameters. Neither of these worked.

Please help.

Jan 13 '06 #1
3 1258
Alex,

Try adding the t=<random>

To the image url instead of the page. IE caches images based on the image
path not the page path. Making it look like the image path has changed will
stop the caching. For example:

http://msdn.microsoft.com/asp.net/art/asprk.jpg?t=1234

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alex Greenberg" <mi*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

I'm having a strange problem:

I have a product.aspx page where the admin can change product
properties, including the JPEG. The JPEG will always have the same
name: eg. 120.jpg and in the same location.

1) Admin visits page and browses to images/myimage.jpg
2) Application takes myimage.jpg and creates a modified copy in
myapp/img and calls it 120.jpg.
3) image path in database changes to myapp/img/120.jpg
3) Admin leaves page
4) Admin revisits page (in same session) and picks a different image,
which replaces the old one but retains the name 120.jpg.
5) Admin leaves and comes back one more time. OLD IMAGE IS STILL
DISPLAYED (from step 2). Even though image is changed on hard drive.

obviously, IE is caching the image and going back to it on subsequent
visits in same session. I tried using the No-Cache directive. I also
added a ?t=<random> to the page parameters. Neither of these worked.

Please help.

Jan 13 '06 #2
Hello S. Justin Gengo [MCP],
Alex,

Try adding the t=<random>

To the image url instead of the page. IE caches images based on the
image path not the page path. Making it look like the image path has
changed will stop the caching. For example:

http://msdn.microsoft.com/asp.net/art/asprk.jpg?t=1234


A better approach is to use HTTP CacheControl headers. Simply configure IIS
to attach the HTTP header CacheControl: no-cache to all images served from
your image directory.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 16 '06 #3
Thanks, I don't have control over the second approach, but the first
one worked perfectly.

Best,

Alex

Jan 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Griffiths | last post by:
Hi all Very new to JavaScript, I am trying to cache a number of images as the page loads, is there a max number of images or memory usage before the browser stops caching. My PC has 1G ram so...
1
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the...
1
by: vip001 | last post by:
Hello This is the site developed for one of my client 'Direct2deal.com' (http://www.direct2deal.com) This site has lots of images and hence downloading time of home page i much more..Is there...
4
by: Jake | last post by:
Does cookieless session state (with the sessionid embedded into the url) interfere with the browser's retrieval of cached images from one session to the next? Does the sessionid embedded into the...
0
docdiesel
by: docdiesel | last post by:
The fastest (and cheapest) transfer of data is that which doesn't have to be done - because the data is already there. Or still there - the caching of files is widely known and practised. Each web...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.