Thanks for your comment. The following is my understanding of what you said.
For example, I will ignore the max-age parameter and limit s-maxage to 60. If the response from origin server contains the headers like: < Cache-Control: s-maxage=180, max-age=360 Then I modify headers in READ_RESPONSE_HDR_HOOK like: < Cache-Control: s-maxage=60 < X-Cache-Control: s-maxage=180, max-age=360 The original value of the second Cache-Control to X-Cache-Control and the value of the second Cache-Control is modified to "s-maxage=60". In SEND_RESPONSE_HDR_HOOK, modify headers back to the original headers. Here is a simplified implementation for the proof of concept. It has limitation that it cannot handle multiple Cache Control Headers ``` function read_response() ts.server_response.header['X-Cache-Control'] = ts.server_response.header['Cache-Control'] ts.server_response.header['Cache-Control'] = 's-maxage=60' return 0 end function send_response() ts.client_response.header['Cache-Control'] = ts.client_response.header['X-Cache-Control'] ts.client_response.header['X-Cache-Control'] = nil return 0 end function do_remap() ts.hook(TS_LUA_HOOK_READ_RESPONSE_HDR, read_response) ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response) return 0 end ``` However the renamed header name X-Cache-Control may collide with the original headers. In my usecase, the origin servers are out of my control, so any header names may be used. And I think it is simpler to implement ignoring and limiting headers in the Traffic Server than modifying and restoring headers in a plugin. After all, I think I will use my original modification as a private patch to the Traffic Server. Regards, Hiroaki 2016-05-13 11:25 GMT+09:00 Sudheer Vinukonda <sudhe...@yahoo-inc.com>: > Hmm..it should be possible to do what you need with a plugin. > > For instance, going back to the solution you tried, perhaps you could > instead of storing the CC headers in the Request context, rename them with > custom names in the Response context (which should get cached) and rename > them as required subsequently? > > "1. In TS_HTTP_READ_RESPONSE_HDR_HOOK, remove Expires and > Cache-Control: max-age headers and keep the values in the request > context. > 2. In TS_HTTP_SEND_RESPONSE_HDR_HOOK, restore Expires and > Cache-Control: max-age headers with the values stored in the request > context." > > > > On Thursday, May 12, 2016, 7:14 PM, Hiroaki Nakamura <hnaka...@gmail.com> > wrote: > > I tried and found that when I modify headers in > TS_HTTP_READ_RESPONSE_HDR_HOOK, > the cached object has those modified headers, so when the next time a > request comes in, > the cached response with the modified headers is served. > > This is not what I want. My requirement is to serve cached objects > with the original headers. > I think it cannot be done with a plugin. > > So here I propose my request for modification again. > >> How about adding a value to proxy.config.http.cache.required_headers? >> >> https://docs.trafficserver.apache.org/en/latest/admin-guide/files/records.config.en.html#proxy-config-http-cache-required-headers >> >> 0 = no headers required to make document cacheable >> 1 = either the Last-Modified header, or an explicit lifetime header, >> Expires orCache-Control: max-age, is required >> 2 = explicit lifetime is required, Expires or Cache-Control: max-age >> 3 (new value) = explicit lifetime is required, Cache-Control: s-maxage >> (Expires or Cache-Control: max-age are ignored). > > Please give me your feedbacks. > > Regards, > > Hiroaki