[Zope] Browser Sticky Fingers

Ian Blenke icblenke@2c2.com
Mon, 18 Oct 1999 17:33:06 -0400


On Tue, Oct 19, 1999, Jeff Rush wrote:

> I'm pulling my hair out here over what is probably a simple HTTP issue.
> I have a Zope method that stuffs a new image into a Zope Image object,
> based on the content of the page where the method is called.

Your IMG tags point to the same URL but the actual image contents
dynamically change?

> The problem is that the image is not updated until I exit the browser,
> and then flush all of it's caches manually.

This is definitely a browser caching issue.

> I've turned off any proxy support, configured Netscape 4.x with the
> option "Document in cache is compared to document on web site [always]",
> and even run the 'curl' utility outside of the browser that prints the
> HTTP headers.  The headers show that the modified date is changing,
> the size is changing (different image sizes), and that there is no expire
> header.  I thought maybe I needed one but noticed that no where in
> the Zope source code do they use one, and when one of their
> images is re-uploaded via the /manage_upload, it displays correctly.
>
> Am I missing something simple?

Here's something simple to do: append a "?randomstring" to the end of
the SRC of your IMG tags, ie:

	<IMG SRC="/Images/myimage_gif?<dtml-var randomstuff>">

Here's a little example that should work. This uses a timestamp to
mark the IMG SRC (based on Bill's "HowTo Autogenererate an Object ID"):

	<dtml-call "REQUEST.set('ts', ZopeTime())">
	<dtml-call "REQUEST.set('randomstuff',_.str(_.int(ts)))">
	<IMG SRC="/Images/myimage_gif?<dtml-var randomstuff>">

This won't help you if you're going to render the Image directly,
the usual:

<dtml-with Image><dtml-var "myimage_gif.tag(randomstuff)"></dtml-with>

just isn't going to work.

If anyone knows how to append such a string with the Image.tag method,
please let us know :)

This is the only "simple" workaround I'm aware of to address this issue.

- Ian C. Blenke <icblenke@2c2.com>