Bart van den Burg
Bart van den Burg

Reputation: 2344

html served from express app on azure is not gzipped

I'm trying to deploy an Angular Universal application to an Azure WebApp running on a Linux service plan. Even tho my browser indicates that it accepts gzip, the server does not encode the response with gzip.

Take for example this URL: https://msp-navigator-dev.azurewebsites.net/assets/logo-mspn.png

No content-encoding.

This file is served by an express server proxying the requested filename from disk. I'm not sure if Azure is misconfigured, or NodeJS, or the webserver or Express JS.

How do I resolve this issue?

Upvotes: 0

Views: 288

Answers (1)

Jay Harris
Jay Harris

Reputation: 10055

You can enable compression in Express using the compression package (npmjs).

npm install compression --save

And in your code:

var compression = require('compression');
var express = require('express');
var app = express();

app.use(compression());

Upvotes: 1

Related Questions