From 9ff6fd103d86aacec0e03b378c62b93e24b1e694 Mon Sep 17 00:00:00 2001 From: Hoang Vo Date: Wed, 25 Nov 2020 03:10:42 -0500 Subject: [PATCH] cache user data --- pages/api/users/[userId]/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pages/api/users/[userId]/index.js b/pages/api/users/[userId]/index.js index 0495666..424ab12 100644 --- a/pages/api/users/[userId]/index.js +++ b/pages/api/users/[userId]/index.js @@ -6,8 +6,11 @@ const handler = nc(); handler.use(all); +const maxAge = 4 * 60 * 60; // 4 hours + handler.get(async (req, res) => { const user = await getUser(req, req.query.userId); + res.setHeader('cache-control', `public, max-age=${maxAge}`); res.send({ user }); });