Coder Social home page Coder Social logo

Comments (9)

BorjaMacedo avatar BorjaMacedo commented on September 20, 2024 1

#65 Solved this!

from serverless-api-gateway-caching.

Jordan-Eckowitz avatar Jordan-Eckowitz commented on September 20, 2024

I changed the endpoint to a GET request with query string parameters and its working. Just out of interest, is there a way to get this to work for a POST request?

I've only ever seen examples using GET but according to the AWS docs it can be done.

from serverless-api-gateway-caching.

DianaIonita avatar DianaIonita commented on September 20, 2024

Hi @Jordan-Eckowitz,

You can define caching on a POST method, however the issue seems to be with cache key parameters.

According to AWS Documentation on request data mapping expressions, it should be possible to use method.request.body or method.request.body.JSONPath_Expression (this plugin simplifies the declaration and omits the method prefix).
However, AWS seems to reject CloudFormation templates which use those mappings.
I also can't find a way in the API Gateway console to click through and add body or a property on the body as a cache key parameter. Maybe I'm missing something though, so please let me know if it's possible through the UI.

In the meantime, I should update the documentation of the plugin and remove request.body and request.body.JSONPath_EXPRESSION as possible cache key parameters.

from serverless-api-gateway-caching.

Jordan-Eckowitz avatar Jordan-Eckowitz commented on September 20, 2024

Hi @DianaIonita,

Thanks for the response and creating this plugin - its saved me a lot of time!

There's a section here called Override API Gateway Stage-Level Caching for Method Caching with details on how to setup custom method caching if an endpoint isn't a GET method. It looks like this would need to be enabled for request body mapping to work.

These are the steps they outline in the docs:

To configure API caching for individual methods using the console:

Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

Go to the API Gateway console.

Choose the API.

Choose Stages.

In the Stages list for the API, expand the stage and choose a method in the API.

Choose Override for this method in Settings.

In the Cache Settings area, you can set or clear Enable Method Cache or customize any other desired options. (This section is shown only if stage-level caching is enabled.)

from serverless-api-gateway-caching.

DianaIonita avatar DianaIonita commented on September 20, 2024

Hi Jordan,

I was looking at that page and I can see options for adding cache key parameters from the query string, header, but nothing about the body:

image

from serverless-api-gateway-caching.

Jordan-Eckowitz avatar Jordan-Eckowitz commented on September 20, 2024

You've got to go to the endpoint under the Stages section of the API.

image

from serverless-api-gateway-caching.

DianaIonita avatar DianaIonita commented on September 20, 2024

Yes, that's already enabled. The issue is with configuring the cache key parameters under Resources.

from serverless-api-gateway-caching.

DianaIonita avatar DianaIonita commented on September 20, 2024

Feel free to reopen this if you have any more information about the issue.

from serverless-api-gateway-caching.

fffan64 avatar fffan64 commented on September 20, 2024

any news on this ? need caching for post body (entire or some specific keys)

from serverless-api-gateway-caching.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.