Merge branch 'feat-server-http-cache-header' into feat-local-develop-and-monitoring

This commit is contained in:
Vittorio Palmisano 2021-03-17 14:34:47 +01:00
commit cda5be098e
2 changed files with 19 additions and 1 deletions

View file

@ -364,6 +364,9 @@ module.exports =
requestTimeout : 20000,
// Socket retries when timeout
requestRetries : 3,
// If > 0, sets a cache-control max-age (in seconds) to the GET response
// headers.
getRequestsCachePeriod : 0,
// Mediasoup settings
mediasoup :
{

View file

@ -87,12 +87,27 @@ const tls =
const app = express();
app.use(helmet.hsts());
const sharedCookieParser=cookieParser();
const sharedCookieParser = cookieParser();
app.use(sharedCookieParser);
app.use(bodyParser.json({ limit: '5mb' }));
app.use(bodyParser.urlencoded({ limit: '5mb', extended: true }));
if (config.getRequestsCachePeriod > 0)
{
app.use((req, res, next) => {
if (req.method === 'GET')
{
res.set('Cache-control', `public, max-age=${config.getRequestsCachePeriod}`)
}
else
{
res.set('Cache-control', 'no-store');
}
next();
});
}
const session = expressSession({
secret : config.cookieSecret,
name : config.cookieName,