Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

gzip compress and cache api response in express

Browsers are really good at under­stand­ing gzipped responses and this cre­ates an oppor­tu­nity for you to decrease the ini­tial page load time and improve your website’s per­for­mance by gzip­ping all of your API responses. This is achieved by tak­ing advan­tage of the content-encoding http header.

It’s par­tic­u­larly easy to do so using express. While at it, we will also see how to eas­ily serve cached sta­tic con­tent from your express server

Install the express and compression pack­age as a dependency

npm i express --save
npm i compression --save

Refer to the fol­low­ing gist for how to set it up in your app.

Watch the fol­low­ing video to see the quick demo of css compression!

Ver­ify that your site is Gzip enabled or not :

Ver­ify the page speed for your site before and after the gzip enabled:

Ref­er­ences :