From c7bf857d384b2b1d2e868f3d55ba6f4c6cae0f9c Mon Sep 17 00:00:00 2001 From: Ashley Date: Mon, 6 Feb 2023 14:23:19 +0000 Subject: [PATCH] add cacher for static files --- server.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server.js b/server.js index 7ac2868..b8ac5b5 100644 --- a/server.js +++ b/server.js @@ -97,6 +97,7 @@ this is our config file,you can change stuff here invapi: "https://invidious.sethforprivacy.com/api/v1", dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=", invchannel:"https://invidious.privacydev.net/api/v1", + cacher_max_age:"1800", enablealwayshttps: true, //enables always https on the server t_url: "https://t.poketube.fun/", // def matomo url }; @@ -124,6 +125,15 @@ this is our config file,you can change stuff here next(); }); + app.use(function (req, res, next) { + if (req.url.match(/^\/(css|js|img|font)\/.+/)) { + res.setHeader('Cache-Control', 'public, max-age=' + config.cacher_max_age); // cache header + res.setHeader("poketube-cacher", "STATIC_FILES"); + + } + next(); +}); + sinit(app, config, renderTemplate); init(app);