Answer the question
In order to leave comments, you need to log in
Is it possible to compress pictures using compression in express 4...?
Here is the code:
compression = require 'compression'
app = module.exports.app = exports.app = express()
app.use(compression())
app.use express.static( path.join(__dirname, '../../public' ) )
showIndexContent = ( req, res ) ->
# res.setHeader('Content-Type', 'text/event-stream')
# res.setHeader('Cache-Control', 'no-cache')
res.sendFile '/',
root: path.join(__dirname, '../../public')
app.get '/', showIndexContent
Answer the question
In order to leave comments, you need to log in
By default, the compression module does not compress pictures. The filter method is responsible for which Content-Type will be compressed (see the documentation) .
By default, the compressible module is used to determine which Content-Type is compressible.
PS There is no practical sense in compressing the same JPEG images. This also applies to other compressed formats such as PNG, GIF. That is why they are absent in the default filter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question