[mod_python] Strange caching problem

Simon Willison cs1spw at bath.ac.uk
Wed Aug 27 22:51:32 EST 2003


I'm experimenting with the idea that mod_python stays resident in 
memory. Here's the handler script I'm using:

from mod_python import apache

counter = 0

def handler(req):
     req.content_type = 'text/html'
     req.send_http_header()
     global counter
     counter = counter + 1
     req.write("Counter: %d" % counter)
     return apache.OK

If I load it up in a browser and continuously hit refresh, the number 
only increments every 4 or 5 page loads. I was expecting it to increment 
each time. Don't worry - this isn't how I intend to implement a page 
counter, it's just an experiment I'm using to try and gain a better 
understanding of this capability.

The above problem is unsevere, but I've also been having issues with the 
following script:

from mod_python import apache

def handler(req):
     req.content_type = 'text/html'
     req.send_http_header()
     req.write('unparsed_uri: %s' % req.unparsed_uri)
     return apache.OK

When I visit the following URL:

http://myserver/~simon/1

It displays this, as expected:

unparsed_uri: /~simon/1

If I then visit the following:

http://myserver/~simon/2

It continues to show the same string. I have to hit enter in my 
browser's location bar several times before it will notice that I've 
entered a different URL.

This is a major problem, as my aim is to serve up different content 
depending on the URL. If the system isn't noticing the different URLs 
for some reason it becomes unusable!

Thanks,

Simon






More information about the Mod_python mailing list