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:
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.
via codeslayer1
No comments:
Post a Comment