]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.js
Server: add cache to static files
[github/Chocobozzz/PeerTube.git] / server.js
index 5feb214764f183f10cd7f8b58e5407ff3ce0a98c..f24b25f4d96fc1501c38349563ef6d56fe75bcd1 100644 (file)
--- a/server.js
+++ b/server.js
@@ -2,6 +2,7 @@
 
 // ----------- Node modules -----------
 const bodyParser = require('body-parser')
+const cors = require('cors')
 const express = require('express')
 const expressValidator = require('express-validator')
 const http = require('http')
@@ -74,15 +75,15 @@ app.use('/client/*', function (req, res, next) {
 })
 
 const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents'))
-app.use(constants.STATIC_PATHS.TORRENTS, express.static(torrentsPhysicalPath, { maxAge: 0 }))
+app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: '7d' }))
 
-// Uploads path for webseeding
-const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads'))
-app.use(constants.STATIC_PATHS.WEBSEED, express.static(uploadsPhysicalPath, { maxAge: 0 }))
+// Videos path for webseeding
+const videosPhysicalPath = path.join(__dirname, config.get('storage.videos'))
+app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(videosPhysicalPath, { maxAge: '7d' }))
 
 // Thumbnails path for express
 const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails'))
-app.use(constants.STATIC_PATHS.THUMBNAILS, express.static(thumbnailsPhysicalPath, { maxAge: 0 }))
+app.use(constants.STATIC_PATHS.THUMBNAILS, express.static(thumbnailsPhysicalPath, { maxAge: '7d' }))
 
 // Client application
 app.use('/*', function (req, res, next) {