Forums

Serve static files directly via nginx

Hello,

I'm currently using PA for a backend/cms sort of application written in web2py, that works great. Now I wanted to host a landing page for the associated mobile application. This site is mainly static code which I'm currently serving via Flask, which works - but seems relatively slow.

So the question is, if there is a possibility to configure your nginx server to directly serve the static files for this page. As I've read in the forums this might not be possible just yet, but maybe you could give me a hint.

Thanks in advance, Philipp

Don't worry, I found this: https://www.pythonanywhere.com/forums/topic/308/ very helpful. It turned out not make such a big difference in loading time.

By copying the files in to /var/www/static/ the content was accessible via <myname>.pythonanywhere.com. I'd be interested in how I could do the same thing with a custom domain.

Thanks + a nice weekend.

Hi there -- glad you found out the workaround! That directory should work for all domains associated with your account.

We're about to start work on a richer level of support for static files, so there are improvements (for example different sets of static files for different domains, and the ability to specify directories for static file URL stubs) coming soon.

Ok, thanks for your response. This feature you mention (serving different static folders for different domains) would be greatly appreciated! :)

Glad to hear it! We're at work on it right now, so we should be able to get it out in a week or so (barring disasters...)

I have a little add on to the question above. I'm still trying to host that static page, with my primary objective being to minimize loadtime. I tried various ways to do this. With Flask, then with Bottle, also I tried to let nginx serve those static files directly. I tried to do the same thing on GAE and then compared loadtimes. GAE w/ bottle performed best I guess.

The question now is, if you (as the guys who know your own infrastructure best) have any hints for me, as to how I could optimize loadtime for static pages on pythonanywhere.

Help would be greatly appreciated.