Comments (8)
Hi @stoverlee,
When I specify request.path.querystring.param1 will it cache as just /test?
If you have settings like:
- http:
path: /test
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.querystring.param1
Then it will create a cache entry for all the different values it may receive of param1
, i.e. one entry for /test?param1=A
, another entry for /test?param1=B
.
Yes, it includes the case when it's undefined
, meaning when it's just /test
.
If I use multivaluequerystring, will it cache all these 3 possibilities: /test?param1=test, /test?param2=test, /test?param1=test¶m2=test?
You're right that the README needs to be updated. I need to add some of what's here - and also that multivaluequerystring
is not supported. The plugin currently only supports cache key parameters coming from header
, path
and querystring
. If you know of a way to define cache key parameters in the API Gateway console for multivaluequerystring
, then there might also be a way to do it in code, but so far I've not been able to find out whether it's possible.
In your example, your parameters would be part of the querystring
, so you'd only need to do this for it to create cache entries for all possiblities of param1
and param2
:
- http:
path: /test
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.querystring.param1
- name: request.querystring.param2
Multi-value query strings would look something like: /test?param=A¶m=B
, so param
would be multi-valued: an array of A
and B
. The plugin doesn't currently support this, as I was mentioning above.
Is there a way to specify a catch all for querystring params, instead of explicitly specifying the params in multivaluequerystring? So I would want to cache on the url + querystringparams whatever the querystring parameters may be
I can only think of a way to have a catch-all for paths:
- http:
path: /test/{proxy+}
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.querystring.proxy
This would allow you to cache any paths to the right of /test/
, so paths like:
/test/param1value/param2value
/test/some/path/here
In lambda code, you would have access to the path variable through the request.pathParameters.proxy
and it would have the values param1value/param2value
and some/path/here
respectively, so you'd need to parse them.
However, this doesn't seem to work for query string parameters, so for the paths:
/test/some/path/here
and/test/some/path/here?query=123
the same cache entry would be created. request.pathParameters.proxy
will always be some/path/here
, regardless of query string. For a user, that would mean that no matter what they changed the query string to, they'd always get the page at /test/some/path/here
.
Please let me know if it doesn't make sense.
Edit: I just noticed this PR on multivaluequerystring
, I'll have a look at whether it's possible to add support.
Later edit: The PR was good, but didn't add support for multivaluequerystring
.
from serverless-api-gateway-caching.
@DianaIonita Hello,
I also have a question on caching, is there a way to invalidate a certain route? Lets say api.domain.com/v2/users/47
route was cached, and I want to invalidate the cache only for that specific user 47
but not for all users. Is there a way to do that once the route was cached for that specific path parameter value? Thanks.
I imagine there is some kind of an endpoint like /invalidations
where you can send the path and cache key parameters for which you want an invalidation to happen.
from serverless-api-gateway-caching.
Hi @pavlelekic,
Yes, you can invalidate specific cache keys by setting the header Cache-Control: max-age=0
in your request to api.domain.com/v2/users/47
.
You might also need to configure per-key cache invalidation authorization with these plugin settings:
custom:
apiGatewayCaching:
enabled: true
perKeyInvalidation:
requireAuthorization: true # default is true
handleUnauthorizedRequests: Fail # default is "IgnoreWithWarning".
from serverless-api-gateway-caching.
Thanks @DianaIonita!
Is there a way to flush the whole cache? Letβs say you deploy a new version of you application, and you want to flush the old cache (for all routes)?
from serverless-api-gateway-caching.
Hi @pavlelekic,
You can do that, for example, via the API Gateway console, in the Stage editor:
from serverless-api-gateway-caching.
Thanks!
from serverless-api-gateway-caching.
How to cache full query string?
I have a complex search and I want to cache it with a full querystring as a key
from serverless-api-gateway-caching.
Hi @vvmspace,
Apologies for the delay. You would use the query string as is as a cache key parameter, for example:
- http:
path: /search
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.querystring.searchParams
Please consider raising another issue if you'd like to have further discussions around this topic.
from serverless-api-gateway-caching.
Related Issues (20)
- client certificate as cacheKeyParameters HOT 7
- Upgrade from 1.7.5 to 1.8.0 breaking API Gateway endpoint HOT 6
- Internal Server Error when setting cache key parameter request.header.Authorization HOT 2
- support for httpApi HOT 1
- Support API Gateway V2 HOT 1
- Support on cache by body on POST request HOT 6
- Serverless Offline error HOT 4
- Caching stops working as soon as I set cacheKeyParameters HOT 1
- Is there a way to invalidate all caches for a specific key? HOT 2
- Invalid logging level specified: null on v1.10.0 HOT 3
- Is it possible to ignore non 200 responses? HOT 1
- Getting a bunch of APIs with "Inherit from stage" unexpectedly HOT 4
- TTL configs not applied by Api Gateway HOT 1
- /proxy - cache miss on every request - NestJs HOT 1
- Support Chinese characters in cacheKeyParameters HOT 4
- New serverless release not compliant with pulgin HOT 2
- cacheKeyParameters are always required as of 1.10.3
- Unable to set cache key from the request context HOT 1
- API gateway cacheKeyParameters error HOT 2
- headers caching for multi-tenant HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-api-gateway-caching.