Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Observed difference in file size between Nginx and Express server when serving static bundles

I am trying to optimize serving my static bundles generated from my React Webpack app. In this process, I noticed that for same files, when serving the content through an Express server, the file sizes were comparatively lower than when served through nginx.

Here is my express code to serve the bundle:

app.use(express.static(project.paths.dist()));

Here is my nginx config:

server {
listen 80;

root /home/test/dist/;
index index.html index.htm app.js;

server_name www.ranodom.com;

location / {
    try_files $uri /index.html;
}

error_log /var/log/nginx/test/website-error_log error;
access_log /var/log/nginx/test/website-access_log;
}

When served through express:

Express served files

When served through nginx: Nginx served files

As visible from above screenshots, the file sizes differ drastically. The actual file sizes as present in the folder is equal to the one being served from Nginx server.

My question is, what can be the reason for this difference? Does express static optimizes/compresses the served files or is there a catch? If there is so much difference, would it be better to serve these files via express server and routing to index page via nginx?

PS. The above files are already uglified and minified using webpack.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Just realized that the compression middleware was enabled in my express server and hence the reduction in size.

If anyone else stumbles on this post, do notice that you can obtain similar results using nginx by using the below mentioned configs.

gzip on;
gzip_min_length 1000;
gzip_types text/html text/css application/javascript text/javascript text/plain text/xml application/json;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda