diff --git a/src/controllers/ldb.controllers.js b/src/controllers/ldb.controllers.js index 83f92f9..5349bdd 100644 --- a/src/controllers/ldb.controllers.js +++ b/src/controllers/ldb.controllers.js @@ -9,7 +9,7 @@ async function getTrain(req, res, next) { err.status = 401; throw err; } - setCache(res, "private", 180) + setCache(res, "private", 240) let type = req.params.searchType; let id = req.params.id; try { @@ -45,8 +45,14 @@ async function getStation(req, res, next) { err.status = 401; return next(err); } - setCache(res, "public", 120) - res.json(await ldb.get(id, true)); + const data = await ldb.get(id, true); + // Only cache if data is present + if (data.data) { + setCache(res, "public", 120); + } else { + setCache(res, "no-store", 120); + } + res.json(data); } else { setCache(res, "public", 240) res.json(await ldb.get(id, false)); diff --git a/src/controllers/ref.controllers.js b/src/controllers/ref.controllers.js index 32e8275..98d9e0d 100644 --- a/src/controllers/ref.controllers.js +++ b/src/controllers/ref.controllers.js @@ -18,6 +18,7 @@ async function getReasonCode(req, res, next) { } catch (err) { console.error("ERROR", err.message); err.status = 500; + setCache(res, "no-store", 5) next(err); } }