Re: [Zope] Zope fine tuning HOW-TO / Zope Performance
To speed things up:
1. Do the kind of optimization you'd do in any programming environment. E.g. move repeated calculations out of loops, etc..
2. Rewrite key sections of your DTML in Python should help.
3. Add caching of results. Sending prerendered data is 5-10 times faster than sending the DTML that generates the data. This is an especially good idea if you're dealing with structured text.
can someone with the know how give us newbies pointers on how to do this. a how to would be great.
4. Add HTTP caching headers so your pages get called less.
this too. i tried generating the headers thru apache, but that didn't really turn out right. it seems that my headers are dated in the past, so zope has to render the page again. would doing it from zope help? i looked at zope.org source and see that zope.org generate the headers with dtml. tried copying it but can't get the right date format. it may seem trivial, even a requirement to being a web developer, but not everybody has access to such previleged kowledge. (meaning me :)) tia
-- Itamar S.T. itamars@ibm.net
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Add HTTP caching headers to your pages ======================================== Let's assume your DTML docs always generate the same content (unless you've changed their DTML code). No stock quotes, no time of day. 1. Add the following code to the beginning of your standard_html_header: <dtml-unless dynamicpage> <dtml-call "httpHandler(this(), REQUEST, RESPONSE)"> </dtml-unless> The unless is there so that pages that DO have dynamic content, such as stock quotes, can skip the http caching by doing <dtml-call "REQUEST.set('dynamicpage', 1)"> before the standard_html_header. 2. Create the following PythonMethod called httpHandler in the root of your site: <params>self, obj, REQUEST, RESPONSE</params> def rfc1123_date(dt): return dt.toZone('GMT').rfc822() # this is our initial assumption - the last time that the DTML was modified # is the last time its output was modified: mod_time = obj.bobobase_modification_time() header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=_.string.split(header, ';')[0] mod_since=int(_.DateTime(header).timeTime()) if int(mod_time) <= mod_since: RESPONSE.setStatus(304) RESPONSE.write('') raise "NotModified", '' # if we havn't sent a 304, send the content with appropiate headers RESPONSE.setHeader('Last-Modified', rfc1123_date(mod_time)) # this page should expire in 15 minutes RESPONSE.setHeader('Expires', rfc1123_date(_.DateTime(_.DateTime().timeTime() + 900)))
On Sun, 16 Apr 2000 18:43:04 +0300, Itamar Shtull-Trauring <itamars@ibm.net> wrote:
header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=_.string.split(header, ';')[0] mod_since=int(_.DateTime(header).timeTime())
if int(mod_time) <= mod_since: RESPONSE.setStatus(304) RESPONSE.write('') raise "NotModified", ''
I don't think that response.write('') is a good idea. It causes ZServer to switch to streaming output mode, which is a little less efficient. In particular HTTP/1.0 clients can't use persistent connections. For other clients the difference isn't great, but still significant. This might be better as..... if int(mod_time) <= mod_since: RESPONSE.setStatus(304) return 1
<dtml-unless dynamicpage> <dtml-call "httpHandler(this(), REQUEST, RESPONSE)"> </dtml-unless>
....and.... <dtml-unless dynamicpage> <dtml-if "httpHandler(this(), REQUEST, RESPONSE)"> <dtml-return "''"> </dtml-if> </dtml-unless> Toby Dickenson tdickenson@geminidataloggers.com
participants (3)
-
Itamar Shtull-Trauring -
kdie -
Toby Dickenson