diff --git a/models/pages/overboard.js b/models/pages/overboard.js index 3ae08e49..223b1536 100644 --- a/models/pages/overboard.js +++ b/models/pages/overboard.js @@ -6,13 +6,16 @@ const { Posts, Boards } = require(__dirname+'/../../db/') module.exports = async (req, res, next) => { - let threads = []; - try { - const listedBoards = await Boards.getLocalListed(); - threads = await Posts.getRecent(listedBoards, 1, overboardLimit, false, false); - } catch (err) { - return next(err); - } + let threads = (await cache.get('overboard')) || []; + if (!threads || threads.length === 0) { + try { + const listedBoards = await Boards.getLocalListed(); + threads = await Posts.getRecent(listedBoards, 1, overboardLimit, false, false); + cache.set('overboard', threads, 60); + } catch (err) { + return next(err); + } + } res .set('Cache-Control', 'public, max-age=60')