[Zope-dev] problems with file caching

Jonothan Farr jfarr@real.com
Mon, 13 Dec 1999 12:29:32 -0800


> Got it!  Or at least why <= wouldn't cache objects at all, and > had caching
> working.  DateTime().timeTime() returns a float (resolution of more than 1
> second).  The If-Modified-Since sends an int (resolution of a second, as
> required by HTTP protocol).  HTTP 1.1 recommends If-Modified-Since send the
> Last-Modified of the cached object.  But the Last-Modified header is
> different than _p_mtime - _p_mtime is a float, most likely not a whole
> number, while Last-Modified only has a resolution of seconds - it's a int.
> So the 304 is never sent if you use 'self._p_mtime <= ms'.  The fix is
> simple:
>
> in lib/python/OFS/Image.py, we do this:
>
>         if int(self._p_mtime) <= ms:
>                 RESPONSE.setStatus(304)
>                 return RESPONSE
>
> instead of:
>
>         if self._p_mtime > ms:
>                 RESPONSE.setStatus(304)
>                 return RESPONSE
>

As it turns out, this doesn't fix my problems. My self._p_mtime is always an
integral number, but ms is often too small by several nanoseconds due to what
looks like a floating point error. This solution always seems to work for me.

         if self._p_mtime <= round(ms, 1):


--jfarr