Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-api-gateway-caching

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-api-gateway-caching - npm Package Compare versions

Comparing version 1.9.0-rc5 to 1.9.0

src/cacheKeyParameters.js

0

.vscode/launch.json

@@ -0,0 +0,0 @@ {

2

package.json
{
"name": "serverless-api-gateway-caching",
"version": "1.9.0-rc5",
"version": "1.9.0",
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.",

@@ -5,0 +5,0 @@ "main": "src/apiGatewayCachingPlugin.js",

@@ -56,2 +56,6 @@ # serverless-api-gateway-caching

## Only supports REST API
This plugin only supports REST API, because HTTP API does not support API Gateway Caching at the time of this writing. See [docs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html).
## Time-to-live, encryption, cache invalidation settings

@@ -151,4 +155,4 @@

- `GET /cats/4` will create a cache entry for `pawId=4` and `catName` as `undefined`.
- `GET /cats/34?catName=Toby` will create a cache entry for `pawId=34` and `catName=Toby`.
- `GET /cats/72?catName=Dixon&furColour=white` will create a cache entry for `pawId=72` and `catName=Dixon`, but will ignore the `furColour` query string parameter. That means that a subsequent request to `GET /cats/72?catName=Dixon&furColour=black` will return the cached response for `pawId=72` and `catName=Dixon`.
- `GET /cats/34?catName=Dixon` will create a cache entry for `pawId=34` and `catName=Dixon`.
- `GET /cats/72?catName=Tsunami&furColour=white` will create a cache entry for `pawId=72` and `catName=Tsunami`, but will ignore the `furColour` query string parameter. That means that a subsequent request to `GET /cats/72?catName=Tsunami&furColour=black` will return the cached response for `pawId=72` and `catName=Tsunami`.

@@ -392,2 +396,49 @@ ### Cache key parameters from the path, query string and header

## Configuring caching when the endpoint bypasses lambda and talks to a service like DynamoDb
This example uses the `serverless-apigateway-service-proxy` plugin which creates the path `/dynamodb?id=cat_id`.
Caching can be configured using the `additionalEndpoints` feature. The method and path must match the ones defined as a service proxy. It also supports cache key parameters.
```yml
plugins:
- serverless-api-gateway-caching
- serverless-apigateway-service-proxy
custom:
apiGatewayCaching:
enabled: true
additionalEndpoints:
- method: GET
path: /dynamodb
caching:
enabled: true
ttlInSeconds: 120
cacheKeyParameters:
- name: request.querystring.id
apiGatewayServiceProxies:
- dynamodb:
path: /dynamodb
method: get
tableName: { Ref: 'MyDynamoCatsTable' }
hashKey:
queryStringParam: id # use query string parameter
attributeType: S
action: GetItem
cors: true
resources:
Resources:
MyDynamoCatsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: my-dynamo-cats
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
```
## More Examples

@@ -394,0 +445,0 @@

'use strict';
const ApiGatewayCachingSettings = require('./ApiGatewayCachingSettings');
const pathParametersCache = require('./pathParametersCache');
const cacheKeyParameters = require('./cacheKeyParameters');
const updateStageCacheSettings = require('./stageCache');

@@ -40,3 +40,3 @@ const { restApiExists, outputRestApiIdTo } = require('./restApiId');

return pathParametersCache.addPathParametersCacheConfig(this.settings, this.serverless);
return cacheKeyParameters.addCacheKeyParametersConfig(this.settings, this.serverless);
}

@@ -43,0 +43,0 @@

@@ -0,0 +0,0 @@ const get = require('lodash.get');

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ const isEmpty = require('lodash.isempty');

@@ -0,0 +0,0 @@ module.exports = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc