Opened 16 years ago

Closed 16 years ago

#8409 closed (fixed)

Django built-in server is very slow with Firefox browser when serving admin media

Reported by: andylowry Owned by: nobody
Component: HTTP handling Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Firefox (v3.0.1) with default settings is taking a very conservative view on cacheability of admin media files served by the Django built-in server in django.core.servers.basehttp.py. This can be dramatically improved by arranging for AdminMediaHandler class to provide Last-Modified headers in its responses. Without this change, IE outperforms Firefox on admin pages by a big margin (apparently its heuristics for cache expiry in this case are far looser).

Change History (7)

comment:1 by James Bennett, 16 years ago

Resolution: invalid
Status: newclosed

The dev server really isn't built for speed.

comment:2 by anonymous, 16 years ago

Has patch: set
Resolution: invalid
Status: closedreopened

I understand that it's not built for speed, but the changes are trivial, and it makes a huge difference (1-second page load vs. about 10 seconds for a not terribly complicated admin page!). I'm sure the dev server gets used very extensively, especially since the tutorial and two different projects books both walk through how to use it (albeit with caveats). I'm reopening this because I think this is such a trivial change with a relatively big payoff that it's worth more serious consideration. But I won't reopen again if I haven't changed your mind this time.

Here are my changes (3 lines added to existing code):

At top of basehttp.py:

    import stat

Later, in the __call__ method:

                status = '200 OK'
		mtime = os.stat(file_path)[stat.ST_MTIME]
                headers = {'Last-Modified': http_date(mtime) }
                mime_type = mimetypes.guess_type(file_path)[0]

comment:3 by Piotr Lewandowski <django@…>, 16 years ago

Component: UncategorizedHTTP handling

comment:4 by marcusl, 16 years ago

I second this. I have to switch between IE and FireFox when developing Django, because IE is fast and FireFox has FireBug.
The difference is that IE is instant and FireFox has a 1-2 second delay (when browsing my regular pages, not the admin), which is enough to impair me a bit.

I applied the patch and it didn't help all the way, but a little bit.

comment:5 by Adrian Holovaty, 16 years ago

andylowry: Thanks for bringing this up. I'm working on a fix. One thing I should note is that the solution is a bit more complicated than setting the Last-Modified header -- we also have to check the HTTP_IF_MODIFIED_SINCE header.

comment:6 by Adrian Holovaty, 16 years ago

Triage Stage: UnreviewedAccepted

comment:7 by Adrian Holovaty, 16 years ago

Resolution: fixed
Status: reopenedclosed

(In [9055]) Fixed #8409 -- The runserver now uses conditional GET for admin media files, instead of reloading the files off disk for every request. Thanks for reporting, andylowry

Note: See TracTickets for help on using tickets.
Back to Top