Optimising caching and enabling gzip for web2py on heroku?

246 views
Skip to first unread message

Alec Taylor

unread,
Mar 2, 2013, 11:51:29 PM3/2/13
to web2py mailing-list
Going through the Google PageSpeed Insights report
(https://developers.google.com/speed/pagespeed/insights) to see what I
should optimise to improve my site-load speed.

The two high priority ones to worry about are:
- Leverage browser caching
- Enable compression

How do I deal with these internally to web2py and on heroku?

(e.g.: Rocket doesn't support gzip; so how do I configure this on
heroku? - All the guides I saw were for Django or Flask…)

FYI: I have also enabled these two lines in my db.py:
response.optimize_css = 'concat,minify,inline'
response.optimize_js = 'concat,minify,inline'

How do I optimize these "High priority" metrics PageSpeed found?

Thanks for all suggestions,

Alec Taylor

Paolo valleri

unread,
Mar 3, 2013, 6:46:59 AM3/3/13
to web...@googlegroups.com
Hi Alec, 
if I were you I would remove the 'inline' parameter from both response.optimize_css response.optimize_js, just to keep the page lighter and to leverage on the browser cache for the external resources.
Moreover, +1 for having something 'automatic' for using somehow the browser cache, in this case the 'somehow' is not clear to me yet.

Paolo

Niphlod

unread,
Mar 3, 2013, 8:55:02 AM3/3/13
to web...@googlegroups.com
response.static_version is the answer for static files cache.
As for gzipping, the default static serving function checks for compressed files (.gz) and if they are present it serves them instead of the original one.
There's a script too to prepare those https://github.com/web2py/web2py/blob/master/scripts/zip_static_files.py

As for gzip support for compressing the html of your dynamic page, there's nothing ready, but adapting something shouldn't be hard.

Yebach

unread,
Mar 11, 2016, 8:52:53 AM3/11/16
to web2py-users
I would like to speed up my page a little bit. one of the suggestions by https://gtmetrix.com is to gzip my files

I am looking at your zip_statis_file.py where do I insert this function?

Kiran Subbaraman

unread,
Mar 11, 2016, 9:19:14 AM3/11/16
to web...@googlegroups.com
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vid Ogris

unread,
Mar 11, 2016, 9:37:09 AM3/11/16
to web...@googlegroups.com
So i gzipped my files. I am running my web2py on windows not on apache or anything. Is is possible to serve them like that or do I have to use Apache server for this to work?

You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/1CcxCblrW6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Kiran Subbaraman

unread,
Mar 12, 2016, 8:45:46 AM3/12/16
to web...@googlegroups.com
Sure, you can use web2py on windows (with its bundled Rocket webserver) to serve your pages. But then Rocket webserver has limited configuration options, as listed on this page: http://web2py.com/books/default/chapter/29/13/deployment-recipes#Deployment-recipes--Infrastructure
A suggestion is to put a webserver in front of your web2py instance which can handle the serving of static files, without having to get web2py to do this (these are the things that you gzipped anyway).
I suggest you look at the "Deployment Recipes" section for more idea to "speed" up your deployment: http://web2py.com/books/default/chapter/29/13/deployment-recipes

________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/

Niphlod

unread,
Mar 13, 2016, 7:02:07 AM3/13/16
to web2py-users
if you're running web2py under iis (and not just using iis as a reverse proxy to the rocket webserver) you need to write a rewrite rule to serve gzipped files.
if static files are handled by web2py it takes care automatically to serve the .gz file instead of the "raw" one if it's existing

the resulting conf would look like

<match url="(.*)" ignoreCase="false" />
	<conditions logicalGrouping="MatchAll">
	        <add input="{REQUEST_METHOD}" pattern="POST" ignoreCase="false" negate="true" />
        	<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" ignoreCase="false" />
	        <add input="{REQUEST_FILENAME}.gz" matchType="IsFile" />
	</conditions>
	<action type="Rewrite" url="{R:0}.gz" />
Reply all
Reply to author
Forward
0 new messages