Performance: MEDIA_URL and MEDIA_ROOT
MEDIUM IMPACT
This concept affects how media files are served and loaded, impacting page load speed and user experience when accessing images, videos, or other uploaded content.
MEDIA_URL = '/media/' MEDIA_ROOT = '/absolute/path/to/media' # Configure a dedicated web server (e.g., Nginx) to serve media files directly # Django only handles dynamic content, media served statically
MEDIA_URL = '/media/' MEDIA_ROOT = '/absolute/path/to/media' # Serving media files via Django's runserver in production urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Serving media via Django dev server | N/A | N/A | High due to slow media load | [X] Bad |
| Serving media via dedicated static server | N/A | N/A | Low, fast media load | [OK] Good |