Skip to content

Commit

Permalink
Merge pull request #5 from zylcom/product-controller
Browse files Browse the repository at this point in the history
feat(product-controller): add expires in response headers
  • Loading branch information
zylcom authored Jul 31, 2023
2 parents 31e3fc4 + dddb324 commit 80d3c8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/controllers/product-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const get = async (req, res, next) => {
const slug = req.params.slug;
const result = await productService.get(slug);

res.status(200).set("Cache-Control", "public, max-age=31536000").json({ data: result });
res
.status(200)
.set({ "Cache-Control": "public, max-age=31536000", Expires: new Date(Date.now() + 5 * 60 * 1000) })
.json({ data: result });
} catch (error) {
next(error);
}
Expand Down Expand Up @@ -39,7 +42,10 @@ const infinite = async (req, res, next) => {
};
const result = await productService.infinite(request);

res.status(200).set("Cache-Control", "public, max-age=31536000").json({ data: result.data, paging: result.paging });
res
.status(200)
.set({ "Cache-Control": "public, max-age=31536000", Expires: new Date(Date.now() + 5 * 60 * 1000) })
.json({ data: result.data, paging: result.paging });
} catch (error) {
next(error);
}
Expand Down

0 comments on commit 80d3c8b

Please sign in to comment.