Refresh Page

D

David

Hello.

I have such problem:
I have ImageButton on my form which is attached to some image like
"image.jpg", now when I change image file (physically file) with some other
file with the same name my page shows the old image until I click "Refresh"
button of the browser.
So how can I refresh web form from code?
Or may be there is some other way to solve this problem?

Thank you.
 
D

David

No! It's imposable.
Is there any other way?

Eliyahu Goldin said:
The image gets cached on client side. You can trick the browser onto
refreshing the image by adding a random number to the image url. For
example
image.jpg?1234

Eliyahu
 
E

Eliyahu Goldin

The image gets cached on client side. You can trick the browser onto
refreshing the image by adding a random number to the image url. For example
image.jpg?1234

Eliyahu
 
E

Eliyahu Goldin

Yes, in the code-behind:

Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
Response.Cache.SetCacheability (System.Web.HttpCacheability.NoCache);

Response.AppendHeader ("Pragma", "no-cache");


Eliyahu
 
J

Joerg Jooss

Eliyahu said:
Yes, in the code-behind:

Response.ExpiresAbsolute = DateTime.Now.AddDays (-1);
Response.Cache.SetCacheability (System.Web.HttpCacheability.NoCache);

Response.AppendHeader ("Pragma", "no-cache");

This only affects the page itself, but not any referenced resource. In order
to make the image file non-cacheable, put all it and all other non-cacheable
images in a common folder and assign this folder the HTTP headers

Cache-Control: no-cache (*)
Pragma: no-cache

using the IIS admin applet.

(*) Technically, "Cache-Control: must-revalidate" would be the right choice,
but IE handles this incorrectly :-(


Cheers,
 
W

William F. Robertson, Jr.

That is the way it should be done. I read a great article about what
yahoo.com does for their impression ads and image tracking. You will need
to put some value on the end of the src.

<img srg="http:\\site.com\images\bob.jpg?5531234">

This will force the client browser to "redownload" the image, as it doesn't
think it has it downloaded already.

bill
 
J

Joerg Jooss

William said:
That is the way it should be done.

Should? No, not really. HTTP 1.1 covers all required cache and expiration
mechanisms. But if you said "must" be done, you're most likely correct.
There are still too many crappy HTTP implementations out there that are
beyond any poor web application developer's control :-(

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top