How to do it...

  1. Create the project from the following template:
$ sls create --template-url https://github.com/danteinc/js-cloud-native-cookbook/tree/master/ch9/cache-control --path cncb-cache-control
  1. Navigate to the cncb-cache-control directory, cd cncb-cache-control.
  2. Review the file named serverless.yml.
  3. Review the file named handler.js with the following content:
module.exports.get = (request, context, callback) => {  const response = {    statusCode: 200,    headers: {      'Cache-Control': 'max-age=5',    },    body: ...,  };  callback(null, response);};module.exports.save = (request, context, callback) => { const response = {   statusCode: 200,   headers: {     'Cache-Control': 'no-cache, no-store, must-revalidate',   }, }; callback(null, response);};
  1. Install ...

Get JavaScript Cloud Native Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.