]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - middlewares/cache.js
Remove useless anonymous functions of files
[github/Chocobozzz/PeerTube.git] / middlewares / cache.js
CommitLineData
9f10b292 1'use strict'
a5fa04b0 2
9f10b292
C
3var cacheMiddleware = {
4 cache: cache
5}
a5fa04b0 6
9f10b292
C
7function cache (cache) {
8 return function (req, res, next) {
9 // If we want explicitly a cache
10 // Or if we don't specify if we want a cache or no and we are in production
11 if (cache === true || (cache !== false && process.env.NODE_ENV === 'production')) {
12 res.setHeader('Cache-Control', 'public')
13 } else {
14 res.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
a5fa04b0 15 }
9f10b292
C
16
17 next()
a5fa04b0 18 }
9f10b292 19}
a5fa04b0 20
9f10b292 21// ---------------------------------------------------------------------------
a5fa04b0 22
9f10b292 23module.exports = cacheMiddleware