All,
    Pondering over with Anthony's solution, I just uploaded images to
static folder and that works wonders for image caching.
Below is the code that I changed in db.py for my model -

    Field('profile_pic', 'upload', uploadfolder=request.folder
+'static/user_pics',  requires=IS_LENGTH(262144)),

Just a minor hiccup that it sometimes or initially loads the images
partially (esp png files, not tried with gif's) . Still, I am happy
with the way images are being rendered now. I will still consider the
below solution from Anthony for more further analysis..

Thanks for getting back so quickly .. .web2py community is superb!

Regards, Rahul D (www.flcokbird.com)


On Feb 13, 9:55 pm, Anthony <abasta...@gmail.com> wrote:
> On Monday, February 13, 2012 5:40:53 AM UTC-5, Rahul wrote:
>
> > Hi All,
> >        I am using the below statement to serialize images in my view
> > -
> > {{=TAG.img(_width=25, _height=30, _src=URL(r=request, c='default',
> > f='download', args=[adminupdate.profile_pic]))}}
>
> Maybe something like:
>
> {{=TAG.img(_width=25, _height=30, _src=URL(r=request, c='default',
> f='download', args=[adminupdate.profile_pic], vars=dict(cache=True)))}}
>
> def download():
>     if 'cache' in request.vars:
>         response.headers['Cache-Control'] = 'max-age=3600'
>     response.download(request, db)
>
> Anthony

Reply via email to