Random ...
 
December 2017
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Tags ...
Links



python+zope++:: Caching web2py controller
Posted at 08.Apr,2011 12:05  Comments 0 / Trackbacks 0 / Like this post!
Technorati tag(s):

In zope we can set the cache header per methods or views (if we so wish).

I usually do this to cache views/methods that use reources and may slow down response; e.g querying 1000 rows and do calculation, etc.

Sometimes I do this just because there's really no change in a view in 5 minutes, or more.

Cache headers can also be set in web2py controller:

  def test():
    del response.headers['Cache-Control']
    del response.headers['Pragma']
    del response.headers['Expires']
    response.headers['Cache-Control']='max-age=300'

     rows=db(db.person).select()
     return dict(rows=rows)

This way the controller will be set to be valid for max-age of 5 minutes. We can also add other cache-control headers.


Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/261/tbping 

Comments
Post a comment