What is the right way to serve static files through a CDN ?

45 views
Skip to first unread message

Louis Amon

unread,
Aug 13, 2014, 11:23:52 AM8/13/14
to web...@googlegroups.com
I am using a CDN and am trying to configure web2py to use it instead of the classic static file service.

So far I've been using pattern-based routes like this :

cdn = 'https://xxxxxxx.cloudfront.net'

routes_in
= (...
             
('/static/$anything', cdn + '/static/$anything'),
                         
...
                         
)


routes_out
= (...
             
('/static/$anything', cdn + '/static/$anything'),
                         
...
                         
)


This basically works, but this has to be implemented on a pattern-based routes.py which means I lose many cool features like map_hyphen, default_application, default_controller mappings...

Is there a way to use a CDN with a parametric router ?

I read somewhere that the host parameter in URL can also be used to setup a CDN, but it seems a bit tedious to find all URL and rewrite them.

Isn't there a variable in gluon.rewrite that I can mess with to trick web2py into serving CDN-based content ?

Cliff Kachinske

unread,
Aug 13, 2014, 5:15:50 PM8/13/14
to web...@googlegroups.com
If, like me, you use the same static files on every page, just hard code them into layout.html.

I realize this may make upgrading more, um, interesting, but it's much simpler than pattern-based routing.
Reply all
Reply to author
Forward
0 new messages