Re: How to serve static compressed files
Stephan Semerad <[email protected]> Tue, 6 Jun 2017 14:00:17 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
On the upload function you use in cherrypy you can for sure use some
compression with shutil...
havent tried it, but thats the way I would go. I use shutil to move and
rename images, so I wouldnt be surprised if you could compress your files.
from shutil import copyfileobj
with open('bigInputfile.txt', 'rb') as input:
with bz2.BZ2File('bigInputfile.txt.bz2', 'wb', compresslevel=9) as output:
copyfileobj(input, output)
On Saturday, May 6, 2017 at 10:17:58 AM UTC+2, [email protected] wrote:
>
> Hello,
>
> I need, for my application, to serve some svg and json files, they are
> served statically and because I also need to reduce their size I would like
> to store them already compressed.
> The good news is that firefox support both brotli and gzip for http
> compression, since the first one is really efficient (more than lzip, gzip
> or xz with max setting), I plan to brotli-compress all my files and save
> disk and bandwidth by serving them as this, with only one decompression
> made at the end. Is is even possible ? and how could I do this with
> cherrypy ? Or may be with gzip ?
>
> Sincerely,
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.