为什么Elixir/Phoenix 1.2中的缓存控制值没有更新?

问题描述:

我已经通过凤凰1.2 JSON API设置....为什么Elixir/Phoenix 1.2中的缓存控制值没有更新?

在router.ex,我管我的JSON端点直通管道如下:

pipeline :api do 
    plug :accepts, ["json"] 
    end 

Whne我尝试添加一个缓存控制值在JSON响应我送回到我的浏览器通过发出请求到GET端点响应头:

conn 
    |> put_resp_header("cache-control", "max-age=2000") 

我没有看到的Cache-Control已更新...

req_headers: [{"host", "localhost:4000"}, {"connection", "keep-alive"},    
    {"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"}, 
...  

你混淆了东西。如果您希望将其作为响应标题,请检查resp_headers,而不是req_headers。否则 - 您应该使用Plug.Conn.put_req_header/3而不是put_resp_header