[Twisted-Python] Re: [Twisted-commits] This forces a last modified header [...]
bruce at cubik.org
Thu Sep 26 19:45:23 EDT 2002
Thanks for the constructive feedback!
Kevin Turner wrote:
>>+ # Set the last modified date to ask the browser to
>>+ # not use a cached version.
> Setting Last-Modified does not ask the browser not to use a cached
> version. Setting Last-Modified *allows* the browser to use a cached
> version. Setting it to now() is not the best way to say "don't use a
> cache", particularly if it had no Last-Modified header on it before.
> Default behaviour is to always send the full page anyway, nothing will
> ever change that to NOT_MODIFIED if you never do setLastModified.
> If you don't want a page to be cached, you must set the conditions under
> which a cache may be used for that page the *first time* you send it.
This sort of thing had worked on a previous project, but I suspect that,
as you said, we were sending the Last-Modified header all the time
rather than only occasionally like my change made.
The reason that things looked like it was not working correctly was due
to some asynch handling of page rendering, which was somewhat amusing.
On a page with 2 widgets that did DB queries and that was the target of
a form submission, this sort of thing could happen:
* Form submission happens on page 1
* Woven stuff runs, runs the form code on the server.
* Commit method fires off asynch DB operation.
* Browser redirect is issued.
* Browser requests target page 2.
* Woven starts to render page 2.
* Widget 1 gets rendered with DB data.
* The asynch DB operation finally runs and commits.
* Widget 2 gets rendered with updated DB data.
* User views page 2.
Due to the nature of widget 2 on page 2, it wasn't obvious that this was
happening originally. Donovan and I are working on making the form
processing parts of Woven asynch friendly now and one of us will
hopefully check something in tonight. Either way, I'll remove the buggy
LastModified code this evening.
> I'm not sure exactly what your situation is, so I won't try to go into
> detail, but I suggest browsing over
Thanks for the pointer. I'll definitely read through that.
More information about the Twisted-Python