How to serve static compressed files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to serve static compressed files

yota.news
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to serve static compressed files

yota.news
I found this, for node.js :

https://www.npmjs.com/package/connect-gzip-static

Middleware for connect: serves compressed files if they exist, falls through to connect-static if they don't, or if browser does not send 'Accept-Encoding' header.

would be good if only it was a cherrypy recipe :)

On Saturday, May 6, 2017 at 10:17:58 AM UTC+2, [hidden email] 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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to serve static compressed files

Stephan Semerad
In reply to this post by yota.news
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, [hidden email] 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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Loading...