Hello, how can i compress the API response of the react call for the better page speed ? nimb.ws/o7QnlS
How can i use Gzip compression in react fetch method ?
You could configure it the server. Before that, you need to know which web server you use. It can be nodejs, nginx, apache etc
But instead of doing that in your server, I would suggest giving that work to Cloudflare. They'll take care of it. They also use brotli (better than gzip) whenever possible
Compressing the API response is the role of your web server. What software your server runs on? For instance, if it is Node.js you can use compression module to achieve gzip compression.
Biplab Malakar
Senior Software Engineer, JavaScript Developer, MEAN Developer, Node.js Developer, MERN Developer, Hybrid Mobile App Developer and ML Develo
App.js const [express, compression] = [require('express'), require('compression')]; const [app, router] = [express(), express.Router()]; app.use(compression()); app.get('/', router); router.get('/', (req, res) => { res.status(200).send({messge: 'compressed response'}) }); app.listen(4000, () => { console.log('server start'); });compress npm