473,671 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ 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 1265
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*********@gm ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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********@joer gjooss.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
7179
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 if it's a physical memory constraint then I think I am away from that. I am trying to cache about 600K images, (this if for an intranet so the page load time is fast) but I need the speed of cached images for the page to work correctly. I seem to...
1
2102
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 images, even worse they are not loading completely. This version includes a (vain) attempt at forcing the banner images to cache. Apart form the caching problem the scripting seems to work Any help welcomed:
1
1568
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 a way , where i can cache these images i javascript????? Your suggestions will be highly appreciate
4
2685
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 url effectively limit client-side image caching to the lifetime of the session? Thanks Jake
0
14785
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 browser is caching the files he formerly requested from the web server. But if the file is to be loaded a second time, still a request is sent to the web server which then usually is answering with a "304 Not modified" as can be seen in his access...
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8603
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.