[mod_python] How to stop PSP Page Cache

Graham Dumpleton grahamd at dscpl.com.au
Tue May 3 19:50:00 EDT 2005


Asif Jan wrote ..
> 
> Hello, I am using mod_python 3.1.4, and doing psp development. The 
> pages work fine without any probelms. However, when I change the psp 
> page on disk the changes are not reflected on the version that is 
> served to client. I am not caching pages at the browser side.
> 
> However restarting the apache server results in correct page being 
> served. Is there a way to tell psp handler not to cache the pages?

Although pages are cached, both the in memory cache and the DBM
caching mechanisms have code in them that should mean that if the
file is changed on disk, it will reload them. Ie., from file cache:

    def get(self, filename, mtime):
        try:
            hits, c_mtime, code = self.cache[filename]
            if mtime != c_mtime:
                del self.cache[filename]
                return None
            else:
                self.cache[filename] = (hits+1, mtime, code)
                return code
        except KeyError:
            return None 

and from DBM cache:

def dbm_cache_get(srv, dbmfile, filename, mtime):

    dbm_type = dbm_cache_type(dbmfile)
    _apache._global_lock(srv, "pspcache")
    try:
        dbm = dbm_type.open(dbmfile, 'c')
        try:
            entry = dbm[filename]
            t, val = entry.split(" ", 1)
            if long(t) == mtime:
                return str2code(val)
        except KeyError: 
            return None
    finally:
        try: dbm.close()
        except: pass
        _apache._global_unlock(srv, "pspcache")

Are you sure you aren't connecting to the server via a proxy with caching
enabled or some other caching system like Squid?

When you make the request after changing the file, do you actually see
a request logged in the Apache log file at that time to indicate that the
request is actually getting through to Apache?

Graham


More information about the Mod_python mailing list