Response being cached by AWS Api Gateway











up vote
1
down vote

favorite
1












I am using the below class to make rest calls. I am making a get call to one of the apis that is exposed. The api returns either true or false. Whem I use invocation.get() the response seems to be cached. Is it the expected behavior when using this class/method. If so , how can I get around this?



javax.ws.rs.client.Invocation;

Invocation.Builder invocation = target.request(acceptType);
final CacheControl cacheControl = new CacheControl();
cacheControl.setNoCache(true);
cacheControl.setMaxAge(1);
cacheControl.setMustRevalidate(true);
cacheControl.setNoStore(true);
invocation.cacheControl(cacheControl);









share|improve this question
























  • For Jersey for rest easy
    – Victor Gubin
    Nov 19 at 17:27










  • @VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
    – Punter Vicky
    Nov 19 at 20:13










  • please correct me if I am wrong
    – Punter Vicky
    Nov 19 at 20:13










  • Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
    – Victor Gubin
    Nov 19 at 20:26










  • I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
    – Punter Vicky
    Nov 19 at 20:52















up vote
1
down vote

favorite
1












I am using the below class to make rest calls. I am making a get call to one of the apis that is exposed. The api returns either true or false. Whem I use invocation.get() the response seems to be cached. Is it the expected behavior when using this class/method. If so , how can I get around this?



javax.ws.rs.client.Invocation;

Invocation.Builder invocation = target.request(acceptType);
final CacheControl cacheControl = new CacheControl();
cacheControl.setNoCache(true);
cacheControl.setMaxAge(1);
cacheControl.setMustRevalidate(true);
cacheControl.setNoStore(true);
invocation.cacheControl(cacheControl);









share|improve this question
























  • For Jersey for rest easy
    – Victor Gubin
    Nov 19 at 17:27










  • @VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
    – Punter Vicky
    Nov 19 at 20:13










  • please correct me if I am wrong
    – Punter Vicky
    Nov 19 at 20:13










  • Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
    – Victor Gubin
    Nov 19 at 20:26










  • I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
    – Punter Vicky
    Nov 19 at 20:52













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I am using the below class to make rest calls. I am making a get call to one of the apis that is exposed. The api returns either true or false. Whem I use invocation.get() the response seems to be cached. Is it the expected behavior when using this class/method. If so , how can I get around this?



javax.ws.rs.client.Invocation;

Invocation.Builder invocation = target.request(acceptType);
final CacheControl cacheControl = new CacheControl();
cacheControl.setNoCache(true);
cacheControl.setMaxAge(1);
cacheControl.setMustRevalidate(true);
cacheControl.setNoStore(true);
invocation.cacheControl(cacheControl);









share|improve this question















I am using the below class to make rest calls. I am making a get call to one of the apis that is exposed. The api returns either true or false. Whem I use invocation.get() the response seems to be cached. Is it the expected behavior when using this class/method. If so , how can I get around this?



javax.ws.rs.client.Invocation;

Invocation.Builder invocation = target.request(acceptType);
final CacheControl cacheControl = new CacheControl();
cacheControl.setNoCache(true);
cacheControl.setMaxAge(1);
cacheControl.setMustRevalidate(true);
cacheControl.setNoStore(true);
invocation.cacheControl(cacheControl);






java amazon-web-services aws-api-gateway






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 23:42

























asked Nov 19 at 17:15









Punter Vicky

3,6912077132




3,6912077132












  • For Jersey for rest easy
    – Victor Gubin
    Nov 19 at 17:27










  • @VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
    – Punter Vicky
    Nov 19 at 20:13










  • please correct me if I am wrong
    – Punter Vicky
    Nov 19 at 20:13










  • Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
    – Victor Gubin
    Nov 19 at 20:26










  • I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
    – Punter Vicky
    Nov 19 at 20:52


















  • For Jersey for rest easy
    – Victor Gubin
    Nov 19 at 17:27










  • @VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
    – Punter Vicky
    Nov 19 at 20:13










  • please correct me if I am wrong
    – Punter Vicky
    Nov 19 at 20:13










  • Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
    – Victor Gubin
    Nov 19 at 20:26










  • I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
    – Punter Vicky
    Nov 19 at 20:52
















For Jersey for rest easy
– Victor Gubin
Nov 19 at 17:27




For Jersey for rest easy
– Victor Gubin
Nov 19 at 17:27












@VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
– Punter Vicky
Nov 19 at 20:13




@VictorGubin In my case the api is python code running in AWS lambda behind AWS API Gateway. When I see a stale response in my client , I don't see a request coming to lambda. So in order to check if api gateway is returning cached response , I tried running the same request multiple times using postman. However I always see the correct response. So I believe the rest client which I had pasted above is somehow caching stale response and returning it occasionally. I believe the links provide ways for ensuring cached data is not being returned from server and doesn't address client side caching
– Punter Vicky
Nov 19 at 20:13












please correct me if I am wrong
– Punter Vicky
Nov 19 at 20:13




please correct me if I am wrong
– Punter Vicky
Nov 19 at 20:13












Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
– Victor Gubin
Nov 19 at 20:26




Check this, caching depends on HTTP request/response headers. Postman uses their own transport (chromium engine), when your JAX-RS provider uses their own, in any case it should depend on HTTP headers (from both client and server sides).
– Victor Gubin
Nov 19 at 20:26












I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
– Punter Vicky
Nov 19 at 20:52




I added the cache control header as specified in my updated post. But it doesn't seem to fix the issue.
– Punter Vicky
Nov 19 at 20:52

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379638%2fresponse-being-cached-by-aws-api-gateway%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379638%2fresponse-being-cached-by-aws-api-gateway%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin