A Caching Issue - I Suspect

S

Smithers

My ASP.NET app enables users to upload photos - after which they can
optionally rotate the photo (90 degrees to the left or right). They just
click a link that causes a postback, and server-side code then manipulates
the image file - after which the aspx page refreshes on the client, showing
the rotated version of the photo.

In testing I have observed that sometimes the image will in fact get rotated
(on the server), but the aspx page in the client will refresh but will not
show the current version of the photo.

Here is a typical test scenario with a test client running XP/Pro/SP2 IE6
connecting to separate Windows Server 2003/IIS6 in a data center accessible
via the Internet (i.e., this testing happens over the Internet):
1. Upload a photo. The aspx page shows original photo. This is good.
2. Click to rotate the photo 90 to the right. The aspx page shows the photo
rotated 90 to the right. This is good.
3. Click again to rotate the photo 90 to the right. The aspx shows the photo
rotated 90 from original, NOT 180 degrees as is saved on the server. The
photo should be upside-down at this point and it's not. This is not good.
4. At this point I can click to rotate the photo 90 degrees right or left -
and the aspx page continues to show it rotated 90 to the right - which was
the very first rotation (in step 2). After every rotation request sent from
the browser, I have verified that the image does, in fact, get rotated. I
verify this by viewing the image directly on/from the server (not through
the browser).

I suspected that the image was getting cached on the test client - but
purging the cache has no effect; rebooting the client has no effect, etc.
The only thing that seems to actually result in the current version of the
rotated photo showing up in the browser is waiting - about 10 minutes or so.

FWIW: the aspx has this at the top:<%@ OutputCache Location="none" %>

Any ideas for where the images are getting cached? What I need is the
ability to rotate the photos in any direction, any number of times during a
session, and have the current version show up in the browser.

Thanks!
 
J

Joerg Jooss

Smithers said:
My ASP.NET app enables users to upload photos - after which they can
optionally rotate the photo (90 degrees to the left or right). They
just click a link that causes a postback, and server-side code then
manipulates the image file - after which the aspx page refreshes on
the client, showing the rotated version of the photo.

In testing I have observed that sometimes the image will in fact get
rotated (on the server), but the aspx page in the client will refresh
but will not show the current version of the photo.

Here is a typical test scenario with a test client running XP/Pro/SP2
IE6 connecting to separate Windows Server 2003/IIS6 in a data center
accessible via the Internet (i.e., this testing happens over the
Internet): 1. Upload a photo. The aspx page shows original photo.
This is good. 2. Click to rotate the photo 90 to the right. The aspx
page shows the photo rotated 90 to the right. This is good.
3. Click again to rotate the photo 90 to the right. The aspx shows
the photo rotated 90 from original, NOT 180 degrees as is saved on
the server. The photo should be upside-down at this point and it's
not. This is not good. 4. At this point I can click to rotate the
photo 90 degrees right or left - and the aspx page continues to show
it rotated 90 to the right - which was the very first rotation (in
step 2). After every rotation request sent from the browser, I have
verified that the image does, in fact, get rotated. I verify this by
viewing the image directly on/from the server (not through the
browser).

I suspected that the image was getting cached on the test client -
but purging the cache has no effect; rebooting the client has no
effect, etc. The only thing that seems to actually result in the
current version of the rotated photo showing up in the browser is
waiting - about 10 minutes or so.

FWIW: the aspx has this at the top:<%@ OutputCache Location="none" %>

Any ideas for where the images are getting cached? What I need is the
ability to rotate the photos in any direction, any number of times
during a session, and have the current version show up in the browser.

I agree that this has to be a caching issue. Try using a HTTP debugger
like Fiddler (www.fiddlertool.com) to check whether your browser really
still sends a new request once the image stops rotating.

Do you use GET or POST as HTTP method?

Cheers,
 
S

Smithers

<<Do you use GET or POST as HTTP method?>>

POST: Here's how I initiate the postback via client-side JavaScript:
function RotateRight() {
__doPostBack('btnRotateRight','');
}

with btnRotateRight being a server-side method that rotates the photo by
using methods of System.Drawing.Image.
 
F

Frank Buchan

When you write the image to the page try making the src link in the format:

"image_name.jpg?t={current time}"

Obviously if it is a GIF file, a different extension, etc., is required.

It is a bit of a hack, but if you set the {current time} to the second you
will get a pretty much unique value. The page will then force load the
image. It works consistently, and as far as I know circumvents evens mart
caching on the client-side because the src is considered new due to the
query string portion. It adds a few bytes to the return, but I suspect that
is a small price to pay.

F Buchan
 
W

Win, Pats

Beautiful! Thanks!


Frank Buchan said:
When you write the image to the page try making the src link in the
format:

"image_name.jpg?t={current time}"

Obviously if it is a GIF file, a different extension, etc., is required.

It is a bit of a hack, but if you set the {current time} to the second you
will get a pretty much unique value. The page will then force load the
image. It works consistently, and as far as I know circumvents evens mart
caching on the client-side because the src is considered new due to the
query string portion. It adds a few bytes to the return, but I suspect
that is a small price to pay.

F Buchan
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top