Hi,
I saw some issues on Gzip compression here, but I can't find a clear solution for this. I'm using Next 2.0 and the site is hosted by Heroku. What do I have to do to get the GZip compression please ?When I test my site on gtmetrix or gidnetwork, I can see the Gzip compression is not enable...
Thanks a lot for helping
I used the following in my express config:
const compression = require('compression');
const express = require('express');
...
const server = express();
server.use(compression());
...
Your need of course to install the compression package, npm install compression --save
hope this helps
Thanks @stefano-DM for helping.
@guillaumeko you can do it as like above or using a proxy infront of your app like nginx or even Cloudflare.
Thanks guys !!!
I just put my complete server.js in case someone have the same question:
`
const express = require('express')
const compression = require('compression')
const next = require('next')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
const server = express()
server.use(compression())
server.get('/page1', (req, res) => {
return app.render(req, res, '/resume', req.query)
})
server.listen(process.env.PORT || 3000, (err) => {
if (err) throw err
console.log('> Ready on http://localhost:3000')
})
})
`
Thnaks
Thanks @guillaumeko used compression in here https://github.com/ashinga48/Fifi-NextJS-ANT-Design-Redux-Styled-JSX-with-SCSS
Most helpful comment
I used the following in my express config:
Your need of course to install the
compressionpackage,npm install compression --savehope this helps