[mod_python] Checking a PSP-generated response before starting to send it..?

Aaron Robinson aaron.robinson at mojoworld.com
Wed Jun 27 07:28:03 EDT 2007

Hi all,


I'm running Apache 2.2.4 on Win32 with mod_python 3.3.1 and Python 2.5.1.

I'm completely new to Apache (and hence mod_python), but am reasonably
proficient with python itself.


I'm working on a web service where all content is generated on the fly, and
am wanting to use PSP to facilitate this.

Making as much use as possible of "304: Not Modified" is extremely important
to this project to reduce bandwidth, which is difficult as I have to
generate the content before I know whether it's different ("been modified")
from the last time I sent it or not..


I previously used a mechanism (not using Apache) where I would generate the
response, then take a hash of it and if it matched the hash of the last
response I sent, I would instead send a "304: Not Modified".

My problem is that when using PSP.run(), the response has already been sent
by the time it's finished being generated, so I have no opportunity to step
in and examine the response to see if sending a 304 is possible.


I'm needing an across-the-board mechanism for dealing with this - I thought
of serializing the "vars" dictionary before passing it in and taking a hash
of that for comparison, but this is hardly full-proof, as it would
(incorrectly) lead to responding with a 304 even with different "session"
information, or, in the slightly odd case that the PSP file made use of
random.random(), etc.


Just a thought: Is there a more general mechanism that can detect identical
content to a previous response on the way out and replace it with a 304?


Thanks in advance,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070627/0b492507/attachment.html

More information about the Mod_python mailing list