NodeJS download slower than chrome Possible to simulate browser

0 votes

It takes almost 10 seconds to download the audio file from here using NodeJS, whereas the same download takes less than a second using the browser. I've tried a variety of request libraries, so it's possible that the source slows down non-browser requests??

Would it be feasible to imitate a browser request or adjust certain settings such that the NodeJS download is as fast as the browser download if this is the case? Thanks!

EDIT: I've tried the following code:

https.get({
  host: q.host,
  path: q.path,
  headers: { 'User-Agent': 'Mozilla/5.0'}
}, (response) => {
  response.pipe(filePath).on('finish', () => {
    console.log('done')
})
May 27, 2022 in Node-js by Vaani
• 7,070 points
886 views

1 answer to this question.

0 votes
It appears that the browser is not downloading the complete audio stream at once, but rather downloading it in chunks via byte ranges so that it can start playing almost instantly. Your nodejs code, on the other hand, is attempting to download the complete audio file. It also appears to be using the QUIC protocol (designed for faster downloads).
answered May 30, 2022 by Neha
• 9,020 points

Related Questions In Node-js

0 votes
1 answer

How to extract request http headers from a request using NodeJS connect?

Hello @kartik, To see a list of HTTP ...READ MORE

answered Jul 15, 2020 in Node-js by Niroj
• 82,840 points
23,226 views
0 votes
1 answer

How to get the _id of inserted document in Mongo database in NodeJS?

Hello @kartik, A shorter way than using second ...READ MORE

answered Sep 7, 2020 in Node-js by Niroj
• 82,840 points
13,766 views
0 votes
1 answer

How to create an Excel File with Nodejs?

Hello @kartik, Just create a file with Tabs ...READ MORE

answered Sep 7, 2020 in Node-js by Niroj
• 82,840 points
2,472 views
0 votes
1 answer

How to run app.js in nodejs?

Hello @kartik, Assuming I have node and npm properly installed on the ...READ MORE

answered Oct 13, 2020 in Node-js by Niroj
• 82,840 points
2,979 views
0 votes
1 answer

How to get path from the request in nodejs?

Hello @kartik, Try this out: var http = require('http'); var ...READ MORE

answered Oct 14, 2020 in Node-js by Niroj
• 82,840 points
4,518 views
0 votes
1 answer

How to provide a mysql database connection in single file in nodejs?

Hello @kartik, You could create a db wrapper ...READ MORE

answered Oct 15, 2020 in Node-js by Niroj
• 82,840 points
9,081 views
0 votes
1 answer

How to split and modify a string in NodeJS?

Hello @kartik, Use split and map function: var str = "123, 124, 234,252"; var ...READ MORE

answered Oct 16, 2020 in Node-js by Niroj
• 82,840 points
1,192 views
0 votes
1 answer

How to run shell script file using nodejs?

Hello @kartik, You could use "child process" module ...READ MORE

answered Oct 16, 2020 in Node-js by Niroj
• 82,840 points
9,503 views
0 votes
1 answer

Is there a way to download videos from YouTube Studio using NodeJS

Try this project in the github repository ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,020 points
1,832 views
0 votes
1 answer

NodeJS - Upload ~36MB file to VirusTotal failing

The VirusTotal file/scan API request has a ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,020 points
861 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP