Commit 18dc0c63c39d09c025bd1bdb19c2af818ad767f5
1 parent
fb8f1174
Utilisation de la compression
Showing
2 changed files
with
11 additions
and
0 deletions
Show diff stats
app/routes.js
... | ... | @@ -2,9 +2,19 @@ var path = require('path'); |
2 | 2 | var api = require('./routes/ApiRtes'); |
3 | 3 | var favicon = require('serve-favicon'); |
4 | 4 | var express = require('express'); |
5 | +var compression = require('compression'); | |
5 | 6 | |
6 | 7 | module.exports = function (app) { |
7 | 8 | |
9 | + app.use(compression({ | |
10 | + filter: function shouldCompress(req, res) { | |
11 | + if (req.headers['x-no-compression']) { | |
12 | + return false; | |
13 | + } | |
14 | + return compression.filter(req, res); | |
15 | + } | |
16 | + })); | |
17 | + | |
8 | 18 | // Statique |
9 | 19 | app.use(favicon(path.normalize(__dirname + '/../public/favicon.ico'))); |
10 | 20 | app.use(express.static(path.normalize(__dirname + '/../public'))); | ... | ... |