Search code examples
pythonweb-applicationsgzippyramid

Python Pyramid gzip renderer


I have a web application written with pyramid frameworks. One of my views is taking three seconds to be downloaded at the client side.
I want it to be served as a gzip file, is it possible to it using a build-in feature of pyramid?


Solution

  • The question here does not discuss why it is slow and if 3 seconds is acceptable. Compressing may add further delay. Instead, the author should show source code in the question and then people can suggest how to make it faster.

    Pyramid has, however, buildin feature called encode_content for this:

    http://docs.pylonsproject.org/projects/pyramid/en/latest/api/response.html#pyramid.response.Response.encode_content

    It will encode content already written to response and then change content-length header.