Reputation: 5462
I have a JSON api setup via Phoenix 1.2....
In router.ex, I pipe my JSON endpoints thru pipeline as follows:
pipeline :api do
plug :accepts, ["json"]
end
Whne I try and add a cache-control value to the response headers in the JSON response I send back to my browser making the request to the GET endpoint via:
conn
|> put_resp_header("cache-control", "max-age=2000")
I don't see that the cache-control has been updated...
req_headers: [{"host", "localhost:4000"}, {"connection", "keep-alive"},
{"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"},
...
Upvotes: 1
Views: 1210
Reputation: 5812
You mixed up things. If you want to have it as a response header, check the resp_headers
, not req_headers
. Otherwise - you should use Plug.Conn.put_req_header/3 and not put_resp_header
.
Upvotes: 1