Why is it that when I send a simple file from express, the client consumes a lot of memory?


When I open the html file from the browser it consumes the following:

enter image description here

But when I send the same file from an Express server, the memory consumption is noticeably higher:

enter image description here

It is true that this is not a huge memory consumption, but it is a VERY noticeable difference, Why is this happening?, is Express sending the client something that I do not know (headers, cookies, something?)?

From the server I just have a single JavaScript file with a single route that sends the html file using Express’s sendFile function:

const express = require('express');
const { join } = require('path');

const server = express();

server.get('/', (_, res) => {
    res.sendFile(join(__dirname, 'render.html'));

server.listen(3000, () => {
    console.log('Server is running in port 3000');

whereas the HTML file you send to the client simply contains the following:

<!DOCTYPE html>
<html lang="es">
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <h1>This is Header</h1>
                <h1>Section 1</h1>
                <h1>Section 2</h1>
            <h2>This is Footer</h2>

there is nothing else.

I tried it from Google Chrome and Edge, I hope you can help me understand c:


They were neither HTTP headers, nor cookies … much less the server, the problem was the extensions for the browser !!!

Apparently when I open the HTML file locally (using the ‘File:’ protocol) the extensions were not running.

This is interesting for me, I don’t know how the browser extensions work and their life cycle, but apparently the extensions share the processes and the memory in the current tab, that is, they share the process and the memory with the application that is being currently running, it wasn’t my memory consuming application, it was browser extensions processes.

Answered By – Grizzly

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published