Compressing the response payload in Django REST?

前端 未结 3 697
悲&欢浪女
悲&欢浪女 2020-12-11 04:25

I was wondering: would it be possible to compress the response payload in Django REST?

At the moment, the response payloads are plain JSON data. However, there\'s qu

3条回答
  •  生来不讨喜
    2020-12-11 05:18

    If you are using the Django / DRF built-in web server rather than Apache or nginx, that uses its own WSGI server, so those methods won't work for you.

    However, Django does have a built-in gzip middleware which you should be able to use, as described in these answers:

    https://stackoverflow.com/a/1864377/2540707
    https://stackoverflow.com/a/14821684/2540707

    That being said, for production use you should be using a real web server rather than Django's built-in one.

提交回复
热议问题