0

I fixed a max-age to 30 seconds on the following request of my api : GET /info

When I do the following command curl -X GET http://localhost:8080/v1/info, I get the expected output:

< HTTP/1.1 200 OK
< X-Powered-By: Express
< Cache-Control: max-age=30
< Content-Type: application/json; charset=utf-8
< Content-Length: 1461
< ETag: W/"5b5-3784247786"
< Date: Thu, 10 Dec 2015 09:18:08 GMT
< Connection: keep-alive

But the weird thing is that when I do another request (curl -X GET http://localhost:8080/v1/info again)

< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 1461
< ETag: W/"5b5-3784247786"
< Date: Thu, 10 Dec 2015 09:18:11 GMT
< Connection: keep-alive

The max-age header dissapear.

I tried that on 2 different virtual machines, and on the other one I get my cache-control header sent back each time, so it works as expected. The curl version (curl 7.19.7) is the same on both server.

krakig
  • 1,515
  • 1
  • 19
  • 33
  • What is the time duration between the 2 consecutive requests that you send? Is it more than or less than 30 seconds? – bIgBoY Dec 10 '15 at 11:09
  • 1-2 seconds max. If I wait for more than 30 seconds, the max-age will appear again – krakig Dec 10 '15 at 11:10
  • See [this](http://stackoverflow.com/questions/2932890/http-cache-control-max-age-must-revalidate). Why don't you try adding `must-revalidate` to the cache-contol header and just for now try setting the value to 1/2 seconds – bIgBoY Dec 10 '15 at 11:12
  • What happens if you use this command: `curl -H 'Cache-Control: no-cache' -X GET http://localhost:8080/v1/info`? This should tell `curl` to generate an HTTP request whose `Cache-Control` request header says to not serve/use any cached data? If this command succeeds, that the header manipulation might not be in `curl` (which doesn't tend to preserve data across multiple shell invocations), but might perhaps be elsewhere... – Castaglia Feb 13 '16 at 03:40

0 Answers0