shinya1020 opened a new pull request #7401: URL: https://github.com/apache/trafficserver/pull/7401
TrafficServer accidentally adds Expires header generated by negative_caching_lifetime to non-negative responses. Due to the addition of Expires header, the expiration of non-negative cache that has neither Cache-Control nor Expires is determined by `proxy.config.http.negative_caching_lifetime` . In this case, the expiration should be determined by heuristic expiration (between `proxy.config.http.cache.heuristic_min_lifetime` and `proxy.config.http.cache.heuristic_max_lifetime` ). Also, this breaks the response to a conditional request. This is caused by https://github.com/apache/trafficserver/commit/8eb68266167d8f8b3fa3a00ca9f6b7889e8ec101 . # How to reproduce ## settings ### records.config ``` CONFIG proxy.config.http.negative_caching_enabled INT 1 CONFIG proxy.config.http.negative_caching_lifetime INT 10 CONFIG proxy.config.http.cache.required_headers INT 0 CONFIG proxy.config.http.insert_response_via_str INT 2 ``` ### remap.config ``` map / https://httpbin.org/ ``` ## unnecessary addition of Expires header 1. purge cache just in case ``` $ curl -X PURGE -D - -s -o /dev/null 'http://localhost:8080/get' ``` 2. send request ``` $ curl -D - -s -o /dev/null 'http://localhost:8080/get' | grep -E '(Date|Expires|Via|Age)' Date: Fri, 18 Dec 2020 00:46:09 GMT Age: 0 Via: https/1.1 traffic_server (ApacheTrafficServer/10.0.0 [cMsSfW]) ``` 3. send request within 10 seconds from step 2 ``` $ curl -D - -s -o /dev/null 'http://localhost:8080/get' | grep -E '(Date|Expires|Via|Age)' Date: Fri, 18 Dec 2020 00:46:09 GMT Expires: Fri, 18 Dec 2020 00:46:19 GMT Age: 7 Via: http/1.1 traffic_server (ApacheTrafficServer/10.0.0 [cHs f ]) ``` The cached response should not contain Expires header. 4. send request after 10 seconds from step 2 ``` $ curl -D - -s -o /dev/null 'http://localhost:8080/get' | grep -E '(Date|Expires|Via|Age)' Date: Fri, 18 Dec 2020 00:46:20 GMT Age: 2 Via: https/1.1 traffic_server (ApacheTrafficServer/10.0.0 [cSsSfU]) ``` ## invalid response to conditional request 1. purge cache just in case ``` $ curl -X PURGE -D - -s -o /dev/null 'http://localhost:8080/response-headers?Last-Modified=Fri%2C+18+Dec+2020+00%3A00%3A00+GMT' ``` 2. send request ``` $ curl -D - -s -o /dev/null -H 'If-Modified-Since: Fri, 18 Dec 2020 00:00:00 GMT' 'http://localhost:8080/response-headers?Last-Modified=Fri%2C+18+Dec+2020+00%3A00%3A00+GMT' | grep -E '(HTTP|Via)' HTTP/1.1 200 OK Via: https/1.1 traffic_server (ApacheTrafficServer/10.0.0 [cMsSfW]) ``` In this case, the response code should be `304 Not Modified` . ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
