Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use headers to be part of the cache key #2753

Closed
DimaNevelev opened this issue Dec 21, 2019 · 4 comments · Fixed by #2754
Closed

Use headers to be part of the cache key #2753

DimaNevelev opened this issue Dec 21, 2019 · 4 comments · Fixed by #2754

Comments

@DimaNevelev
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We are working in a multi-tenancy environment. The tenant is defined by a custom header.
We want the ability to manage the cache per tenant.

Describe the solution you'd like
We would like to have a field per API that can be populated by header names.
The headers values should be part of the cache key so in case of changed value a new cache key will be generated.

Describe alternatives you've considered
None

Additional context
Nope

@DimaNevelev DimaNevelev changed the title Use headers to be part of the cache key Extend cache abilities Dec 25, 2019
@DimaNevelev DimaNevelev changed the title Extend cache abilities Use headers to be part of the cache key Dec 25, 2019
buger pushed a commit that referenced this issue Feb 13, 2020
…eOnlyResponseCodes per method and the ability to use headers as part of the cache key (#2753 #2763) (#2754)

Example of a use-case:
We want to cache put/post methods that receive 401 or 403. 
Next time the same request is received we will return the response from the cache unless they change the authorization or tenant headers.

This PR contains:
- Cache support for all of the methods, it can be set from the endpoint designer
- Each cache endpoint can have its own list of ResponseCodes that will override the main API cache list for this endpoint
- Added a list of headers per endpoint that will be inserted (with header values) into the cache key
- Some refactoring to reuse some methods
- Tests

More info can be found in the feature requests #2753 and #2763

Closes #2753 
Closes #2763
buger pushed a commit that referenced this issue Feb 13, 2020
…eOnlyResponseCodes per method and the ability to use headers as part of the cache key (#2753 #2763) (#2754)

Example of a use-case:
We want to cache put/post methods that receive 401 or 403.
Next time the same request is received we will return the response from the cache unless they change the authorization or tenant headers.

This PR contains:
- Cache support for all of the methods, it can be set from the endpoint designer
- Each cache endpoint can have its own list of ResponseCodes that will override the main API cache list for this endpoint
- Added a list of headers per endpoint that will be inserted (with header values) into the cache key
- Some refactoring to reuse some methods
- Tests

More info can be found in the feature requests #2753 and #2763

Closes #2753
Closes #2763
@ilijabojanovic
Copy link
Member

@buger
On latest release-1.9 branch

On endpoint designer we can only enable cache get method, if we add post or put dashboard api returning error:

[Mar  5 11:17:02] ERROR Couldn't unmarshal API data: json: cannot unmarshal object into Go struct field ExtendedPathsSet.api_definition.version_data.versions.extended_paths.cache of type string

Video:
cache

@ilijabojanovic ilijabojanovic reopened this Mar 5, 2020
@DimaNevelev
Copy link
Contributor Author

@ilijabojanovic and @buger ,
I seem to me that this is somthing related to the dashboard, i.e. I can't help you with this.
Am I right?

@buger
Copy link
Member

buger commented Mar 15, 2020

@ilijabojanovic can't replicate it. So far works for me. Also, your video does not show error as well.
If you still can replicate it, pick me for a call.

@buger buger closed this as completed Mar 15, 2020
@ilijabojanovic
Copy link
Member

Done

tykbot bot pushed a commit that referenced this issue Apr 14, 2020
…eOnlyResponseCodes per method and the ability to use headers as part of the cache key (#2753 #2763) (#2754)

Example of a use-case:
We want to cache put/post methods that receive 401 or 403. 
Next time the same request is received we will return the response from the cache unless they change the authorization or tenant headers.

This PR contains:
- Cache support for all of the methods, it can be set from the endpoint designer
- Each cache endpoint can have its own list of ResponseCodes that will override the main API cache list for this endpoint
- Added a list of headers per endpoint that will be inserted (with header values) into the cache key
- Some refactoring to reuse some methods
- Tests

More info can be found in the feature requests #2753 and #2763

Closes #2753 
Closes #2763

(cherry picked from commit dcc58b1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants