Hello everyone.

Am trying to populate a page with around 20 dynamic images from the upload 
folder, but they get rendered extremely slow, even as thumbnails. Tried 
using a suggest approach from the forum "fast_download()", but without luck 
in my case. 

Anyone has a suggestion, what should I be looking at, and how to improve 
the speed of loading dynamic images? 

Platform: clean ubuntu node with web2py and nginx (no caching setup, 1Gb of 
ram). Nothing else is running on it.

Performed following three tests:

Regular download():
Compressed images (through PIL, with extension .thumbnail): 
http://www.webpagetest.org/result/130822_1F_WAD/ (500Kb in 25 sec)
Regular size images: http://www.webpagetest.org/result/130822_5K_ZSX/ (3Mb 
in 26 sec)

Fast_Download() with regular size images:
http://www.webpagetest.org/result/130822_C3_1008/ (3Mb in 28 sec)

Tried to implement caching in nginx site config, but that disabled images 
completely, and I couldn't get it to work:

#location ~* ^.+\.(jpg|jpeg|gif)$ {
#   root         /home/www-data/web2py/applications/;
#   access_log   off;
#   expires      30d;
#}

or 

#location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
 #    access_log off;
 #    log_not_found off;
 #    expires 180d;
 #}

Fast download used: 
def fast_download():
    session.forget(response)
    cache.action(time_expire=604800)(lambda: 0)()

    # very basic security (only allow fast_download on 
your_table.upload_field):
    if not request.args(0).startswith("product.image"):
    return download()

    filename = os.path.join(request.folder,'uploads',request.args(0))

    return response.stream(open(filename,'rb'))


Segment of the code that displays the images:

                        <div id="prod_img" itemprop="image">
                            {{if p.image:}}
                                <a href="{{=product_link}}">
                {{
                #big_regex = re.compile('|'.join(map(re.escape, 
IMAGE_EXTENSIONS)))
                #tmb_image = big_regex.sub(INDEX_TMB, p.image)
                }}
                                <img src="{{=URL('download', args=p.image, 
scheme=True, host=True)}}" 
                    alt="{{=product_name}}" href="{{=product_link}}" height=
"180px" width="160px"/>
                                </a>
                            <img data-src='{{=tmb_image}}' >
                                {{pass}}
                        </div>




 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to