views:

327

answers:

4

I'm using the Django manage.py runserver for developing my application (obviously), but it takes 10 seconds to completely load a page because the development server is very, very slow at serving static media.

Is there any way to speed it up or some kind of workaround? I'm using Windows 7.

+3  A: 

Consider using mod_wsgi instead, and having httpd handle the static media.

Ignacio Vazquez-Abrams
+1: Don't speed it up. Consider fixing your development environment to use a proper server. Or, consider finding out why your static media is so slow.
S.Lott
How do I set up mod_wsgi in a way that it will function like the development server, reloading any changes automatically?A quick Google search returned something that seemed to be a solution that didn't work in Windows.
Veeti
There is an entry in the wiki there specifically on reloading, with a section that discusses Win32 issues.
Ignacio Vazquez-Abrams
What's interesting, is that the reloading code from mod_wsgi works for any Django management command, which means you can have auto-restart of management script on e.g. svn update.
Tomasz Zielinski
+3  A: 

Development server is simple unsafe single-threaded application, so you cannot do much.

One trick you could try is to redirect /site_media to second development server, but this is ugly and probably wouldn't help that much. So you could try bundling/compressing multiple assets into one css/js (e.g. using YUI Compressor).

And in any case, you should have separate static media server, that can serve multiple assets at once.

Tomasz Zielinski
+2  A: 

Install Firefox (if you haven't already), and install the Firebug Add-On. Restart your browser. In the lower-right corner click the "bug" icon and make sure that in the "Network" tab (it's a dropdown) of the Firebug panel that opens at the bottom of the browser, the network monitor is active.

Now with the network tab of Firebug open, open your Django-generated page that you observed to load slowly. Take a look at the timeline bars. You'll notice that the colored fragment(s) of each bar indicate(s) the reason for each request's total "load" time. Violet, for instance, means that actually the browser is waiting for the server to generate the response. Gray means it's receiving content. And so on. Hovering over the bars will display a color legend.

With Firebug's network monitor you should be able to pinpoint how exactly your browser and/or server are spending their 10 seconds.

Hope that helps.

prometheus
The actual download of an asset doesn't take any time, but the development server can apparently only handle one request at a time, causing the slowness (?).
Veeti
"one request at a time" - it's because it's single threaded so all requests are serialized in queue.
Tomasz Zielinski
A: 

Run lighttpd to serve the static content and use the MEDIA_URL to point the pages at the lighttpd server that servers the static stuff.

Mark0978