My django.contrib.staticfiles settings seems to be ok as all static files get served as expected. However, eg. /static/*.css files do not get gzipped although I have GZipMiddleware turned on.
Fyi. my views html actually does get gzipped, only the files served by the staticfiles app dont. Seems these responses dont go through the middleware chain?
The trick is to have the development server run with the '--nostatic' flag set: ./manage.py runserver --nostatic
.
One then can user a url pattern for serving the static files like so:
if settings.DEBUG:
static_pattern = r'^%s(?P<path>.*)$' % (settings.STATIC_URL[1:],)
urlpatterns += patterns('django.contrib.staticfiles.views',
url(static_pattern, 'serve', {'show_indexes': True}),
)
When run without --nostatic, django will automatically serve things under STATIC_URL without going through the middleware chain.
Thanks to Dave for his pointers!