1

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?

idanuda
  • 494
  • 5
  • 19
  • 1
    Related, not exactly what you're asking for: http://stackoverflow.com/questions/6618985/gzipping-all-http-traffic-with-pyramid – Ilja Everilä May 26 '16 at 07:16
  • I'm locking for a solution for a specific view file... – idanuda May 26 '16 at 07:30
  • This question is not clear. Do you want to serve a static asset as a .gzip, use gzip compression at the web server level, or something else? – Steve Piercy May 26 '16 at 08:21
  • I want to serve the static as a gzip, but I want to figure out if the pyramid framework has it as a build in feature.... – idanuda May 26 '16 at 09:38

1 Answers1

1

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.

Mikko Ohtamaa
  • 69,174
  • 40
  • 208
  • 346