Forum Discussion

akshays's avatar
8 months ago

http.client.request is caching the response being received from the third-party API. Not required.

http.client.request is caching the response being received from the third-party API for about 5 seconds( approx ,the actual value can be different ).

(Ex: 

<#assign translatedResp = http.client.request("https","${url}","${endpoint}").
parameter("key","${apiKey}").header("Content-Type","application/json").body("${bodyObjString}", "application/json").post()/>

)


The use-case I am looking at is using one particular endpoint to make separate calls with different parameters one after the other. But, I am not able to do so since the endpoint is returning the same response even after the call made is different, with different parameters.

If I do set a delay of about 5 seconds after every call, it is able to respond back the fresh response, but it is not optimal to have this much delay.

How do I set the output/response to not be cached at all?

  • Have you tried adding a random string to the end of the URL?   ?…&r=<random string>

2 Replies

  • Have you tried adding a random string to the end of the URL?   ?…&r=<random string>

  • akshays's avatar
    akshays
    Ace
    8 months ago

    Yes, that works. Thanks a lot!

    Sharing for reference:

    <#assign randomNum = "${utils.numbers.randomIntWithCeiling(CEILING_LIMIT)}">


    <#assign translatedResp = http.client.request("https","${url}","${endpoint}").
    parameter("key","${apiKey}").parameter("c","${randomNum}").header("Content-Type","application/json").header("Cache-Control","no-cache, no-store, must-revalidate, private").body("${bodyObjString}", "application/json").post()/>