Skip to content

Commit

Permalink
cache user data
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangvvo committed Nov 25, 2020
1 parent 5b2523e commit 9ff6fd1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pages/api/users/[userId]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});

Expand Down

1 comment on commit 9ff6fd1

@vercel
Copy link

@vercel vercel bot commented on 9ff6fd1 Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.