If your images are fairly large they are going to be slow no matter what. You probably need two versions, a mini thumbnail version, and then the original. On your main page just display the thumbnails, they will load quite fast, but you can link them to the original.
-- Thadeus On Tue, May 4, 2010 at 10:21 PM, mdipierro <[email protected]> wrote: > With apache you can do > > AliasMatch ^/appname/default/customDownload/(.*) > \ > /home/www-data/web2py/applications/appname/uploads/ > $1 > <Directory /home/www-data/web2py/applications/appname/uploads/ >> > Order > Allow,Deny > Allow from > all > </Directory> > > On May 4, 10:17 pm, Yannick <[email protected]> wrote: >> Hehe Thanks for the note... >> >> Thanks for the clarification... The Html loading is not slow it's fine >> BUT loading the pictures are still kind of slow even when I only >> stream them... here is a code I have in my custom download method: >> def customDownload(): >> >> response.stream(open(os.path.join(request.folder,folderName,request.args(0)) >> ,'rb')) >> >> Is there any others techniques available in Web2py that can help me >> speed the Pictures loading process ? >> >> Any ideas please let me know. >> >> Thanks... >> >> On May 4, 9:29 pm, mdipierro <[email protected]> wrote: >> >> > show -> slow. >> >> > Note to self: do not type in the dark. >> >> > On May 4, 8:16 pm, Massimo Di Pierro <[email protected]> wrote: >> >> > > You need to understand why it is show. It is show to load the age or >> > > to load the pictures (because there are lots of the m in the page)? >> > > caching the select only affect the time to download the html page but >> > > does not affect the pictures since you are caching the list of >> > > function names not not the actual pictures. >> >> > > I suspect that the problem is that the system is doing database access >> > > for each picture (that is what download() does), in order to check >> > > whether the user is allowed to view the picture. If you do not need to >> > > validate each picture, you can write your own download function that >> > > does not perform validation and only does streaming or (better) you >> > > can ask web2py to bypass web2py and serve images directly. >> >> > > On May 4, 2010, at 6:36 PM, Yannick wrote: >> >> > > > Hello mate, >> >> > > > I used a lot of pictures in my application. Currently what I'm doing >> > > > is I cache the DAL Select like this: >> > > > "db(....).select(db.photo.fileupload, db.photo.id, cache=(cache.ram, >> > > > 3600))" >> >> > > > And when the users upload new pictures, in the "onaccept" function I >> > > > clear the cache like this: >> > > > - cache.ram.clear() >> > > > So that the cache will be refreshed when the user load back the >> > > > pictures again. >> >> > > > - First, I want to know if it is a good approach ? >> > > > - Second, it is a better way to improve this design to make my system >> > > > faster ? (Because it is still a bit slow) >> > > > - Third, when I do this "cache.ram.clear" it actually clear the cache >> > > > for all users sessions, how can I only clear the cache of a single >> > > > user session NOT all of them ??? >> >> > > > Please let me know. >> >> > > > Cheers, >> > > > Yannick P. >

