From 74939942d0bb02b6786e4344a5145c4219c6f45c Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 27 Dec 2022 20:02:36 +0000 Subject: [PATCH 1/8] Added test converage for caching behavior in the following areas: - no-store and no-cache cache-control directives in request/response - authorization headers - cookie-related request/response --- tests/gold_tests/cache/cache-auth.test.py | 121 ++++++ tests/gold_tests/cache/cache-control.test.py | 212 ++++++++- tests/gold_tests/cache/cache-cookie.test.py | 251 +++++++++++ .../cache/replay/auth-default.replay.yaml | 65 +++ .../cache/replay/auth-ignored.replay.yaml | 64 +++ .../replay/cache-control-pragma.replay.yaml | 100 ----- .../cookie-all-but-text-with-excp.replay.yaml | 404 ++++++++++++++++++ .../replay/cookie-all-but-text.replay.yaml | 348 +++++++++++++++ .../replay/cookie-bypass-cache.replay.yaml | 238 +++++++++++ .../replay/cookie-cache-img-only.replay.yaml | 241 +++++++++++ .../cache/replay/cookie-default.replay.yaml | 240 +++++++++++ .../request-cache-control-default.replay.yaml | 125 ++++++ ...est-cache-control-honor-client.replay.yaml | 127 ++++++ ...response-cache-control-default.replay.yaml | 126 ++++++ ...response-cache-control-ignored.replay.yaml | 126 ++++++ 15 files changed, 2675 insertions(+), 113 deletions(-) create mode 100644 tests/gold_tests/cache/cache-auth.test.py create mode 100644 tests/gold_tests/cache/cache-cookie.test.py create mode 100644 tests/gold_tests/cache/replay/auth-default.replay.yaml create mode 100644 tests/gold_tests/cache/replay/auth-ignored.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cookie-default.replay.yaml create mode 100644 tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml create mode 100644 tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml create mode 100644 tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml create mode 100644 tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml diff --git a/tests/gold_tests/cache/cache-auth.test.py b/tests/gold_tests/cache/cache-auth.test.py new file mode 100644 index 00000000000..4178fdd2f7e --- /dev/null +++ b/tests/gold_tests/cache/cache-auth.test.py @@ -0,0 +1,121 @@ +''' +Test authorization-related caching behaviors +''' +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Test.Summary = ''' +Test authorization-related caching behaviors +''' + +Test.ContinueOnFail = True + +# **testname is required** +testName = "" + + +class AuthDefaultTest: + # Verify the proper caching behavior for request/response containing + # auth-related fields when ATS is in default configuration + authDefaultReplayFile = "replay/auth-default.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "auth-default-verifier-server", + self.authDefaultReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-auth-default") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + # Verify log for skipping the WWW-Authenticate response + self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( + "response has WWW-Authenticate, response is not cacheable", + "Verify ATS doesn't store the response with WWW-Authenticate.") + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "auth-default-client", + self.authDefaultReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +AuthDefaultTest().run() + + +class AuthIgnoredTest: + # Verify the proper caching behavior for request/response containing + # auth-related fields when ATS is configured to bypass caching for those + authIgnoredReplayFile = "replay/auth-ignored.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "auth-ignored-verifier-server", + self.authIgnoredReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-auth-ignored") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Configure ATS to ignore the WWW-Authenticate header in + # response(allow caching of such response) + "proxy.config.http.cache.ignore_authentication": 1 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "auth-ignored-client", + self.authIgnoredReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +AuthIgnoredTest().run() diff --git a/tests/gold_tests/cache/cache-control.test.py b/tests/gold_tests/cache/cache-control.test.py index 2f00136af4c..1bab4be38f8 100644 --- a/tests/gold_tests/cache/cache-control.test.py +++ b/tests/gold_tests/cache/cache-control.test.py @@ -75,7 +75,8 @@ tr.Processes.Default.Streams.stdout = "gold/cache_and_req_body-hit.gold" tr.StillRunningAfter = ts -# Test 3 - response with no cache control, so cache-miss every time +# Test 3 - response doesn't have cache control directive, so cache-miss every +# time tr = Test.AddTestRun() tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( port=ts.Variables.port) @@ -83,15 +84,7 @@ tr.Processes.Default.Streams.stdout = "gold/cache_no_cc.gold" tr.StillRunningAfter = ts -# Test 4 - Cache-Control: no-cache (from client), so cache miss every time -tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control:no-cache\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( - port=ts.Variables.port) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_no_cc.gold" -tr.StillRunningAfter = ts - -# Test 5 - hit stale cache. +# Test 4 - hit stale cache. tr = Test.AddTestRun() tr.Processes.Default.Command = "sleep 15; printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( port=ts.Variables.port) @@ -99,7 +92,7 @@ tr.Processes.Default.Streams.stdout = "gold/cache_hit_stale.gold" tr.StillRunningAfter = ts -# Test 6 - only-if-cached. 504 "Not Cached" should be returned if not in cache +# Test 5 - only-if-cached. 504 "Not Cached" should be returned if not in cache tr = Test.AddTestRun() tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control: only-if-cached\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Cache-control: max-age=300\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( port=ts.Variables.port) @@ -133,8 +126,7 @@ # -# Verify correct handling of cache-control no-cache and interaction with pragma header -# +# Verify correct interaction between cache-control no-cache and pragma header # ts = Test.MakeATSProcess("ts-cache-control-pragma") ts.Disk.records_config.update({ @@ -152,3 +144,197 @@ tr.Processes.Default.StartBefore(server) tr.Processes.Default.StartBefore(ts) tr.StillRunningAfter = ts + + +class RequestCacheControlDefaultTest: + # Verify the proper handling of cache-control directives in requests in + # default configuration + requestCacheControlReplayFile = "replay/request-cache-control-default.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "request-cache-control-default-verifier-server", + self.requestCacheControlReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-request-cache-control-default") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "request-cache-control-default-client", + self.requestCacheControlReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +RequestCacheControlDefaultTest().run() + + +class RequestCacheControlHonorClientTest: + # Verify the proper handling of cache-control directives in requests when + # ATS is configured to honor client's request to bypass the cache + requestCacheControlReplayFile = "replay/request-cache-control-honor-client.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "request-cache-control-honor-client-verifier-server", + self.requestCacheControlReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-request-cache-control-honor-client") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Configured to honor client requests to bypass the cache + "proxy.config.http.cache.ignore_client_no_cache": 0 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + # Verify logs for the request containing no-cache + self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( + "Revalidate document with server", + "Verify that ATS honors the no-cache and performs a revalidation.") + # Verify logs for the request containing no-store + self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( + "client does not permit storing, and cache control does not say to ignore client no-cache", + "Verify that ATS honors the no-store.") + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "request-cache-control-honor-client-client", + self.requestCacheControlReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +RequestCacheControlHonorClientTest().run() + + +class ResponseCacheControlDefaultTest: + # Verify the proper handling of cache-control directives in responses in + # default configuration + responseCacheControlReplayFile = "replay/response-cache-control-default.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "response-cache-control-default-verifier-server", + self.responseCacheControlReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-response-cache-control-default") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + # Verify logs for the response containing no-cache or no-store + self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( + "server does not permit storing and config file does not indicate that server directive should be ignored", + "Verify that ATS honors the no-cache(or no-store) in response and bypasses the cache.") + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "response-cache-control-client-default", + self.responseCacheControlReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +ResponseCacheControlDefaultTest().run() + + +class ResponseCacheControlIgnoredTest: + # Verify the proper handling of cache-control directives in responses when + # ATS is configured to ignore server's request to bypass the cache + responseCacheControlReplayFile = "replay/response-cache-control-ignored.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "response-cache-control-ignored-verifier-server", + self.responseCacheControlReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-response-cache-control-ignored") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + "proxy.config.http.cache.ignore_server_no_cache": 1 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + # Verify logs for the response containing no-cache or no-store + self.ts.Disk.traffic_out.Content += Testers.ExcludesExpression( + "server does not permit storing and config file does not indicate that server directive should be ignored", + "Verify that ATS ignores the no-cache(or no-store) in response and caches the responses despite their presence.") + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "response-cache-control-client-ignored", + self.responseCacheControlReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +ResponseCacheControlIgnoredTest().run() diff --git a/tests/gold_tests/cache/cache-cookie.test.py b/tests/gold_tests/cache/cache-cookie.test.py new file mode 100644 index 00000000000..2f879ae7972 --- /dev/null +++ b/tests/gold_tests/cache/cache-cookie.test.py @@ -0,0 +1,251 @@ +''' +Test cookie-related caching behaviors +''' +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Test.Summary = ''' +Test cookie-related caching behaviors +''' + +Test.ContinueOnFail = True + +# **testname is required** +testName = "" + + +class CookieDefaultTest: + # Verify the correct caching behavior when ATS is in default configuration + cookieDefaultReplayFile = "replay/cookie-default.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "cookie-default-verifier-server", + self.cookieDefaultReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-cookie-default") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "cookie-default-client", + self.cookieDefaultReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +CookieDefaultTest().run() + + +class CookieBypassTest: + # Verify the correct caching behavior when ATS is configured to not cache + # response to cookie for any content type + cookieBypassReplayFile = "replay/cookie-bypass-cache.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "cookie-bypass-verifier-server", + self.cookieBypassReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-cookie-bypass") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Bypass cache for any responses to cookies + "proxy.config.http.cache.cache_responses_to_cookies": 0 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "cookie-bypass-client", + self.cookieBypassReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +CookieBypassTest().run() + + +class CookieImgOnlyTest: + # Verify the correct caching behavior when ATS is configured to cache + # response to cookie only for image content type + cookieImgOnlyReplayFile = "replay/cookie-cache-img-only.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "cookie-img-only-verifier-server", + self.cookieImgOnlyReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-cookie-img-only") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Cache only for image types + "proxy.config.http.cache.cache_responses_to_cookies": 2 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "cookie-img-only-client", + self.cookieImgOnlyReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +CookieImgOnlyTest().run() + + +class CookieAllButTextTest: + # Verify the correct caching behavior when ATS is configured to cache + # response to cookie for all but text types + cookieAllButTextReplayFile = "replay/cookie-all-but-text.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "cookie-all-but-text-verifier-server", + self.cookieAllButTextReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-cookie-all-but-text") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Cache all content type except text + "proxy.config.http.cache.cache_responses_to_cookies": 3 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "cookie-all-but-text-client", + self.cookieAllButTextReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +CookieAllButTextTest().run() + + +class CookieAllButTextWithExcpTest: + # Verify the correct caching behavior when ATS is configured to cache all + # content types but text, but with a few exceptions for text types which + # would also be cached + cookieAllButTextReplayFile = "replay/cookie-all-but-text-with-excp.replay.yaml" + + def __init__(self): + self.setupOriginServer() + self.setupTS() + + def setupOriginServer(self): + self.server = Test.MakeVerifierServerProcess( + "cookie-all-but-text-with-excp-verifier-server", + self.cookieAllButTextReplayFile) + + def setupTS(self): + self.ts = Test.MakeATSProcess("ts-cookie-all-but-text-with-excp") + self.ts.Disk.records_config.update({ + "proxy.config.diags.debug.enabled": 1, + "proxy.config.diags.debug.tags": "http", + # Cache all content type but text. Text type also gets cached for + # server responses without Set-Cookie or with Cache-Control: public + "proxy.config.http.cache.cache_responses_to_cookies": 4 + }) + self.ts.Disk.remap_config.AddLine( + f"map / http://127.0.0.1:{self.server.Variables.http_port}/", + ) + + def runTraffic(self): + tr = Test.AddTestRun() + tr.AddVerifierClientProcess( + "cookie-all-but-text-with-excp-client", + self.cookieAllButTextReplayFile, + http_ports=[self.ts.Variables.port], + other_args='--thread-limit 1') + tr.Processes.Default.StartBefore(self.server) + tr.Processes.Default.StartBefore(self.ts) + tr.StillRunningAfter = self.server + tr.StillRunningAfter = self.ts + + def run(self): + self.runTraffic() + + +CookieAllButTextWithExcpTest().run() diff --git a/tests/gold_tests/cache/replay/auth-default.replay.yaml b/tests/gold_tests/cache/replay/auth-default.replay.yaml new file mode 100644 index 00000000000..deff6057ce6 --- /dev/null +++ b/tests/gold_tests/cache/replay/auth-default.replay.yaml @@ -0,0 +1,65 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_authentication is set to 0(current default) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify the response containing WWW-Authenticate is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/auth + headers: + fields: + - [uuid, cc-www-auth-response] + - [Host, example.com] + + server-response: + status: 401 + reason: Unauthorized + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [WWW-Authenticate, "Basic"] + + proxy-response: + status: 401 + + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/auth + headers: + fields: + - [uuid, cc-www-auth-response-verify] + - [Host, example.com] + - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] + + server-response: + status: 200 + reason: OK + + # Verify that the new 200 response is returned instead of the 401 + proxy-response: + status: 200 diff --git a/tests/gold_tests/cache/replay/auth-ignored.replay.yaml b/tests/gold_tests/cache/replay/auth-ignored.replay.yaml new file mode 100644 index 00000000000..aeb5932feba --- /dev/null +++ b/tests/gold_tests/cache/replay/auth-ignored.replay.yaml @@ -0,0 +1,64 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_authentication is set to 1 +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify that response containing WWW-Authenticate is cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/auth + headers: + fields: + - [uuid, cc-www-auth-response] + - [Host, example.com] + + server-response: + status: 401 + reason: Unauthorized + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [WWW-Authenticate, "Basic"] + + proxy-response: + status: 401 + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/auth + headers: + fields: + - [uuid, cc-www-auth-response-verify] + - [Host, example.com] + - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] + + server-response: + status: 200 + reason: OK + + # Verify that the cached 401 response is returned + proxy-response: + status: 401 diff --git a/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml b/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml index 01044254641..5cd57131789 100644 --- a/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml @@ -74,105 +74,6 @@ sessions: fields: - [ Content-Length, { value: 5, as: equal}] - # Cache-Control: no-cache will not cache - - client-request: - method: "GET" - version: "1.1" - url: /cc/no-cache - headers: - fields: - - [ uuid, cc-no-cache] - - [ Host, example.com ] - - server-response: - status: 200 - reason: OK - headers: - fields: - - [ Content-Length, 4 ] - - [ Cache-Control, "no-cache" ] - - proxy-response: - status: 200 - headers: - fields: - - [ Content-Length, { value: 4, as: equal}] - # Re-request to make sure it was not cached - - client-request: - method: "GET" - version: "1.1" - url: /cc/no-cache - headers: - fields: - - [ uuid, cc-no-cache-verify] - - [ Host, example.com ] - - server-response: - status: 200 - reason: OK - headers: - fields: - # change content length to differentiate from the previous - # response to verify it was not cached. - - [ Content-Length, 5 ] - - [ Cache-Control, "no-cache" ] - - proxy-response: - status: 200 - headers: - fields: - - [ Content-Length, { value: 5, as: equal}] - - # Cache-Control: no-store also does not cache - - client-request: - method: "GET" - version: "1.1" - url: /cc/no-store - headers: - fields: - - [ uuid, cc-no-store] - - [ Host, example.com ] - - server-response: - status: 200 - reason: OK - headers: - fields: - - [ Content-Length, 4 ] - - [ Cache-Control, "no-cache" ] - - proxy-response: - status: 200 - headers: - fields: - - [ Content-Length, { value: 4, as: equal}] - # Re-request to make sure it was not cached - - client-request: - method: "GET" - version: "1.1" - url: /cc/no-cache - headers: - fields: - - [ uuid, cc-no-store-verify] - - [ Host, example.com ] - - server-response: - status: 200 - reason: OK - headers: - fields: - # change content length to differentiate from the previous - # response to verify it was not cached. - - [ Content-Length, 5 ] - - [ Cache-Control, "no-cache" ] - - proxy-response: - status: 200 - headers: - fields: - - [ Content-Length, { value: 5, as: equal}] - - # Pragma: no-cache is ignored if cache-control is specified - client-request: method: "GET" @@ -215,4 +116,3 @@ sessions: headers: fields: - [ Content-Length, { value: 4, as: equal}] - diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml new file mode 100644 index 00000000000..600502901e2 --- /dev/null +++ b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml @@ -0,0 +1,404 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.cache_responses_to_cookies is set to 4(cache cookie to +# responses for all but text types, except text type responses without +# Set-Cookie or with Cache-Control: public) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify that response containing Set-Cookie with image content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that response containing Set-Cookie with video content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-vid + headers: + fields: + - [uuid, set-cookie-vid-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # video content type + - [Content-Type, "video/mp4"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-vid + headers: + fields: + - [uuid, set-cookie-vid-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that response containing Set-Cookie with text content type is not + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify response with image content type for a cookie-containing request + # is cached(since it's not text type) + - client-request: + method: "GET" + version: "1.1" + url: /cookie/img + headers: + fields: + - [uuid, cookie-img-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/img + headers: + fields: + - [uuid, cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with video content type for a cookie-containing request + # is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/vid + headers: + fields: + - [uuid, cookie-vid-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # video content type + - [Content-Type, "video/mp4"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/vid + headers: + fields: + - [uuid, cookie-vid-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with text content type for a cookie-containing request + # is also cached as the server response doesn't contain the Set-Cookie + # directive + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text-response-no-set-cookie + headers: + fields: + - [uuid, cookie-response-text-no-set-cookie] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # note this response doesn't contain the Set-Cookie directive + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text-response-no-set-cookie + headers: + fields: + - [uuid, cookie-response-text-no-set-cookie-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with text content type for a cookie-containing request + # is cached as the response contain Cache-Control: public + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text-response-has-cc-public + headers: + fields: + - [uuid, cookie-response-text-has-cc-public] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + # note this response contains the Cache-Control: public + - [Cache-Control, "max-age=5,public"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text-response-has-cc-public + headers: + fields: + - [uuid, cookie-response-text-has-cc-public-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml new file mode 100644 index 00000000000..89f5d5a2a99 --- /dev/null +++ b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml @@ -0,0 +1,348 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.cache_responses_to_cookies is set to 3(cache all but +# text types) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify that response containing Set-Cookie with image content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that response containing Set-Cookie with video content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-vid + headers: + fields: + - [uuid, set-cookie-vid-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # video content type + - [Content-Type, "video/mp4"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-vid + headers: + fields: + - [uuid, set-cookie-vid-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that response containing Set-Cookie with text content type is not + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify response with image content type for a cookie-containing request + # is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with video content type for a cookie-containing request + # is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-vid + headers: + fields: + - [uuid, cookie-vid-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # video content type + - [Content-Type, "video/mp4"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-vid + headers: + fields: + - [uuid, cookie-vid-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with text content type for a cookie-containing request + # is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # text content type + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] diff --git a/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml new file mode 100644 index 00000000000..decf4c43cda --- /dev/null +++ b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml @@ -0,0 +1,238 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.cache_responses_to_cookies is set to 0(bypass cache +# for any responses to cookie) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify that response containing Set-Cookie with text content type is not + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify that response containing Set-Cookie with image content type is + # not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify response with text content type for a cookie-containing request + # is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify response with image content type for a cookie-containing request + # is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] diff --git a/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml new file mode 100644 index 00000000000..37f50cda5e2 --- /dev/null +++ b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml @@ -0,0 +1,241 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.cache_responses_to_cookies is set to 2(cache only for +# image types) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify that response containing Set-Cookie with text content type is not + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify that response containing Set-Cookie with image content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify response with text content type for a cookie-containing request + # is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # text content type + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-text + headers: + fields: + - [uuid, cookie-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify response with image content type for a cookie-containing request + # is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/cookie-img + headers: + fields: + - [uuid, cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response from the server + - [Content-Length, { value: 4, as: equal }] diff --git a/tests/gold_tests/cache/replay/cookie-default.replay.yaml b/tests/gold_tests/cache/replay/cookie-default.replay.yaml new file mode 100644 index 00000000000..d7e8aab6cb3 --- /dev/null +++ b/tests/gold_tests/cache/replay/cookie-default.replay.yaml @@ -0,0 +1,240 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.cache_responses_to_cookies is set to 1(current +# default, cache for any content-type) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Verify the response containing Set-Cookie with text content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-text + headers: + fields: + - [uuid, set-cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify the response containing Set-Cookie with image content type is + # cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + - [Set-Cookie, "tasty_cookie=strawberry"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/set-cookie-img + headers: + fields: + - [uuid, set-cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify the response with text content type for a cookie-containing + # request is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text + headers: + fields: + - [uuid, cookie-text-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Content-Type, "text/html"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/text + headers: + fields: + - [uuid, cookie-text-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify the response with image content type for a cookie-containing + # request is cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/img + headers: + fields: + - [uuid, cookie-img-response] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + # image content type + - [Content-Type, "image/jpeg"] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached + - client-request: + method: "GET" + version: "1.1" + url: /cookie/img + headers: + fields: + - [uuid, cookie-img-response-verify] + - [Host, example.com] + - [Cookie, "tasty_cookie=strawberry"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # Use a different Content-Length to differentiate between two + # responses + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] diff --git a/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml new file mode 100644 index 00000000000..673c12e1b56 --- /dev/null +++ b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml @@ -0,0 +1,125 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_client_no_cache is set to 1(current default) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Populating the cache + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-cache + headers: + fields: + - [uuid, request-cc-no-cache] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request and verify that Cache-Control: no-cache in the request is + # ignored by making sure cached response was used + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-cache + headers: + fields: + - [uuid, request-cc-no-cache-verify] + - [Host, example.com] + - [Cache-Control, "no-cache"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify the cached response is used + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify that this is the cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that Cache-Control: no-store in the request is ignored + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-store + headers: + fields: + - [uuid, request-cc-no-store] + - [Host, example.com] + - [Cache-Control, "no-store"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the previous response was cached despite the + # no-store directive in the previous request + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-store + headers: + fields: + - [uuid, request-cc-no-store-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] diff --git a/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml new file mode 100644 index 00000000000..f4f636d26de --- /dev/null +++ b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml @@ -0,0 +1,127 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_client_no_cache is set to 0(honoring the client +# requests to bypass the cache) +# +meta: + version: "1.0" + +sessions: + - transactions: + # Populating the cache + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-cache + headers: + fields: + - [uuid, request-cc-no-cache] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request and verify that Cache-Control: no-cache in the request is + # honored by making sure non-cached response was used + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-cache + headers: + fields: + - [uuid, request-cc-no-cache-verify] + - [Host, example.com] + - [Cache-Control, "no-cache"] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify the non-cached response is returned + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] + + # Verify that Cache-Control: no-store in the request is honored + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-store + headers: + fields: + - [uuid, request-cc-no-store] + - [Host, example.com] + - [Cache-Control, "no-store"] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request and verify that Cache-Control: no-store in the previous + # request is honored by making sure the previous response is not cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/request-no-store + headers: + fields: + - [uuid, request-cc-no-store-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify it was not cached. + - [Content-Length, 5] + + eroxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] diff --git a/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml new file mode 100644 index 00000000000..04afc9a3c3b --- /dev/null +++ b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml @@ -0,0 +1,126 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_server_no_cache is set to 0(current default, +# meaning the cache-control directives in responses to bypass the cache is +# honored) +meta: + version: "1.0" + +sessions: + - transactions: + # Verify Cache-Control: no-cache in response is honored + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-cache + headers: + fields: + - [uuid, response-cc-no-cache] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [Cache-Control, "no-cache"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request and make sure non-cached response is used, verifying that + # Cache-Control: no-cache in the previous response is honored + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-cache + headers: + fields: + - [uuid, response-cc-no-cache-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify the non-cached response is returned + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # make sure this is a non-cached response + - [Content-Length, { value: 5, as: equal }] + + # Verify that Cache-Control: no-store in the response is honored + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-store + headers: + fields: + - [uuid, response-cc-no-store] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [Cache-Control, "no-store"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure the response was not cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-store + headers: + fields: + - [uuid, response-cc-no-store-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify it was not cached. + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the new response from the server + - [Content-Length, { value: 5, as: equal }] diff --git a/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml new file mode 100644 index 00000000000..64f1433739e --- /dev/null +++ b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml @@ -0,0 +1,126 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# This replay file assumes that caching is enabled and +# proxy.config.http.cache.ignore_server_no_cache is set to 1(meaning the +# cache-control directives in responses to bypass the cache is ignored) +meta: + version: "1.0" + +sessions: + - transactions: + # Verify the no-cache in response is ignored and the response is cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-cache + headers: + fields: + - [uuid, response-cc-no-cache] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [Cache-Control, "no-cache"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request and make sure cached response is used, verifying that + # Cache-Control: no-cache in the response is ignored + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-cache + headers: + fields: + - [uuid, response-cc-no-cache-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify the non-cached response is returned + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # make sure this is a cached response + - [Content-Length, { value: 4, as: equal }] + + # Verify that Cache-Control: no-store in the response is ignored and the + # response is cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-store + headers: + fields: + - [uuid, response-cc-no-store] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [Cache-Control, "no-store"] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + # Re-request to make sure it was cached + - client-request: + method: "GET" + version: "1.1" + url: /cc/response-no-store + headers: + fields: + - [uuid, response-cc-no-store-verify] + - [Host, example.com] + + server-response: + status: 200 + reason: OK + headers: + fields: + # change content length to differentiate from the previous + # response to verify it was not cached. + - [Content-Length, 5] + + proxy-response: + status: 200 + headers: + fields: + # Verify this is the cached response + - [Content-Length, { value: 4, as: equal }] From 28423a8dc2af395bc69153a30f4582aca5869c54 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 19:41:59 +0000 Subject: [PATCH 2/8] update documentation for certain cache behaviors --- .../configuration/cache-basics.en.rst | 91 ++++++++++--------- doc/admin-guide/files/records.config.en.rst | 4 +- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/doc/admin-guide/configuration/cache-basics.en.rst b/doc/admin-guide/configuration/cache-basics.en.rst index ffdace636e4..ffffc33247f 100644 --- a/doc/admin-guide/configuration/cache-basics.en.rst +++ b/doc/admin-guide/configuration/cache-basics.en.rst @@ -178,14 +178,14 @@ To specify an absolute freshness limit: Specifying Header Requirements ------------------------------ -To further ensure freshness of the objects in the cache, configure -Traffic Server to cache only objects with specific headers. By default, -Traffic Server caches all objects (including objects with no headers); -you should change the default setting only for specialized proxy -situations. If you configure Traffic Server to cache only HTTP objects -with ``Expires`` or ``max-age`` headers, then the cache hit rate will be -noticeably reduced (since very few objects will have explicit expiration -information). +To further ensure freshness of the objects in the cache, Traffic Server by +default caches only HTTP objects with ``Expires`` or ``max-age`` headers. It can +also be configured to cache all objects (including objects with no headers). +Different configurations of header requirements would have a noticeable effect +on cache hit rate. For instance, if Traffic Server is configured to to cache +only HTTP objects with ``Expires`` or ``max-age`` headers(default setting), then +the cache hit rate will be noticeably reduced (since very few objects will have +explicit expiration information). To configure Traffic Server to cache objects with specific headers: @@ -207,12 +207,12 @@ Traffic Server bases the servability of a cached object on ``Cache-Control`` headers that appear in both client requests and server responses. The following ``Cache-Control`` headers affect whether objects are served from cache: -- The ``no-cache`` header, sent by clients, tells Traffic Server that - it should not serve any objects directly from the cache. When present in a - client request, Traffic Server will always obtain the object from the - origin server. You can configure Traffic Server to ignore client - ``no-cache`` headers. Refer to `Configuring Traffic Server to Ignore Client no-cache Headers`_ - for more information. +- The ``no-cache`` header, sent by clients, tells Traffic Server that it should + not serve any objects directly from the cache. When present in a client + request, Traffic Server will always obtain the object from the origin server. + By default, Traffic Server ignores this header. You can configure Traffic + Server to honor client ``no-cache`` headers. Refer to `Configuring Traffic + Server to Honor Client no-cache Headers`_ for more information. - The ``max-age`` header, sent by servers, is compared to the object age. If the age is less than ``max-age``, then the object is fresh @@ -374,18 +374,18 @@ and files. Client Directives ----------------- -By default, Traffic Server does not cache objects with the following -request headers: - -- ``Authorization`` +Configurations can be set to determine whether to cache objects with the +following client directives (By default, Traffic Server caches objects with +these request headers): - ``Cache-Control: no-store`` - ``Cache-Control: no-cache`` - To configure Traffic Server to ignore this request header, refer to - `Configuring Traffic Server to Ignore Client no-cache Headers`_. - + To configure Traffic Server to honor the ``Cache-Control: no-store`` and + ``Cache-Control: no-cache`` request headers, refer to `Configuring Traffic + Server to Honor Client no-cache Headers`_. + - ``Cookie`` (for text objects) By default, Traffic Server caches objects served in response to @@ -394,21 +394,26 @@ request headers: cache all cookied content, or cache cookied content that is of image type only. For more information, refer to `Caching Cookied Objects`_. -Configuring Traffic Server to Ignore Client no-cache Headers +Configuring Traffic Server to Honor Client no-cache Headers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default, Traffic Server strictly observes client -``Cache-Control: no-cache`` directives. If a requested object contains a -``no-cache`` header, then Traffic Server forwards the request to the -origin server even if it has a fresh copy in cache. You can configure -Traffic Server to ignore client ``no-cache`` directives such that it -ignores ``no-cache`` headers from client requests and serves the object -from its cache. +By default, Traffic Server ignores client ``Cache-Control: no-cache`` +directives. Even if a requested object contains a ``no-cache`` header, Traffic +Server serves the object from its cache. You can configure Traffic Server to +honor this header and forwards the request to the origin server even if it has a +fresh copy in cache. + +By default, Traffic Server also ignores client ``Cache-Control: no-store`` +directives. Traffic Server caches response from the server regardless of the +``no-store`` headers from client requests. + +You can configure Traffic Server to honor both client directives with the +following: #. Edit :ts:cv:`proxy.config.http.cache.ignore_client_no_cache` in :file:`records.config`. :: - CONFIG proxy.config.http.cache.ignore_client_no_cache INT 1 + CONFIG proxy.config.http.cache.ignore_client_no_cache INT 0 #. Run the command :option:`traffic_ctl config reload` to apply the configuration changes. @@ -420,19 +425,18 @@ headers: - ``Cache-Control: no-store`` -- ``Cache-Control: private`` - -- ``WWW-Authenticate`` +- ``Cache-Control: no-cache`` - To configure Traffic Server to ignore ``WWW-Authenticate`` headers, - refer to `Configuring Traffic Server to Ignore WWW-Authenticate Headers`_. + To configure Traffic Server to ignore ``no-cache`` and ``no-store`` headers, + refer to `Configuring Traffic Server to Ignore Server no-cache Headers`_. -- ``Set-Cookie`` +- ``Cache-Control: private`` -- ``Cache-Control: no-cache`` +- ``WWW-Authenticate`` - To configure Traffic Server to ignore ``no-cache`` headers, refer to - `Configuring Traffic Server to Ignore Server no-cache Headers`_. + To configure Traffic Server to ignore ``WWW-Authenticate`` headers and cache + the corresponding objects, refer to `Configuring Traffic Server to Ignore + WWW-Authenticate Headers`_. - ``Expires`` header with a value of 0 (zero) or a past date. @@ -547,18 +551,17 @@ Caching Cookied Objects By default, Traffic Server caches objects served in response to requests that contain cookies. This is true for all types of objects including -text. Traffic Server does not cache cookied text content because object -headers are stored along with the object, and personalized cookie header -values could be saved with the object. With non-text objects, it is -unlikely that personalized headers are delivered or used. +text. You can reconfigure Traffic Server to: - Not cache cookied content of any type. +- Cache all cookied content regardless of type. + - Cache cookied content that is of image type only. -- Cache all cookied content regardless of type. +- Cache all cookied content except text type. To configure how Traffic Server caches cookied content: diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index ba9cc02169d..f3028148fc6 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -2207,8 +2207,8 @@ Cache Control .. ts:cv:: CONFIG proxy.config.http.cache.ignore_authentication INT 0 :overridable: - When enabled (``1``), |TS| ignores ``WWW-Authentication`` headers in responses ``WWW-Authentication`` headers are removed and - not cached. + When enabled (``1``), |TS| ignores ``WWW-Authentication`` headers in + responses and the responses are cached. .. ts:cv:: CONFIG proxy.config.http.cache.cache_urls_that_look_dynamic INT 1 :reloadable: From 05b3a5cd8ec6624b05c0d8a4ff1b365a62380c1e Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 20:12:00 +0000 Subject: [PATCH 3/8] remove trailing whitespaces --- doc/admin-guide/configuration/cache-basics.en.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/admin-guide/configuration/cache-basics.en.rst b/doc/admin-guide/configuration/cache-basics.en.rst index ffffc33247f..14b60f51748 100644 --- a/doc/admin-guide/configuration/cache-basics.en.rst +++ b/doc/admin-guide/configuration/cache-basics.en.rst @@ -385,7 +385,7 @@ these request headers): To configure Traffic Server to honor the ``Cache-Control: no-store`` and ``Cache-Control: no-cache`` request headers, refer to `Configuring Traffic Server to Honor Client no-cache Headers`_. - + - ``Cookie`` (for text objects) By default, Traffic Server caches objects served in response to @@ -401,14 +401,14 @@ By default, Traffic Server ignores client ``Cache-Control: no-cache`` directives. Even if a requested object contains a ``no-cache`` header, Traffic Server serves the object from its cache. You can configure Traffic Server to honor this header and forwards the request to the origin server even if it has a -fresh copy in cache. +fresh copy in cache. By default, Traffic Server also ignores client ``Cache-Control: no-store`` directives. Traffic Server caches response from the server regardless of the -``no-store`` headers from client requests. +``no-store`` headers from client requests. You can configure Traffic Server to honor both client directives with the -following: +following: #. Edit :ts:cv:`proxy.config.http.cache.ignore_client_no_cache` in :file:`records.config`. :: From f8c3ead8da71827c57f1fd5937838cd0889616ad Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 21:32:09 +0000 Subject: [PATCH 4/8] reformated the doc --- .../configuration/cache-basics.en.rst | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/doc/admin-guide/configuration/cache-basics.en.rst b/doc/admin-guide/configuration/cache-basics.en.rst index 14b60f51748..148ac92aa70 100644 --- a/doc/admin-guide/configuration/cache-basics.en.rst +++ b/doc/admin-guide/configuration/cache-basics.en.rst @@ -182,8 +182,8 @@ To further ensure freshness of the objects in the cache, Traffic Server by default caches only HTTP objects with ``Expires`` or ``max-age`` headers. It can also be configured to cache all objects (including objects with no headers). Different configurations of header requirements would have a noticeable effect -on cache hit rate. For instance, if Traffic Server is configured to to cache -only HTTP objects with ``Expires`` or ``max-age`` headers(default setting), then +on cache hit rate. For instance, if Traffic Server is configured to cache only +HTTP objects with ``Expires`` or ``max-age`` headers (the default setting), then the cache hit rate will be noticeably reduced (since very few objects will have explicit expiration information). @@ -375,7 +375,7 @@ Client Directives ----------------- Configurations can be set to determine whether to cache objects with the -following client directives (By default, Traffic Server caches objects with +following client directives (by default, Traffic Server caches objects with these request headers): - ``Cache-Control: no-store`` @@ -398,17 +398,17 @@ Configuring Traffic Server to Honor Client no-cache Headers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, Traffic Server ignores client ``Cache-Control: no-cache`` -directives. Even if a requested object contains a ``no-cache`` header, Traffic -Server serves the object from its cache. You can configure Traffic Server to -honor this header and forwards the request to the origin server even if it has a -fresh copy in cache. +directives. Even if a requested object contains a ``no-cache`` directive, +Traffic Server serves the object from its cache. You can configure Traffic +Server to honor this header and forward the request to the origin server even +if it has a fresh copy in cache. -By default, Traffic Server also ignores client ``Cache-Control: no-store`` -directives. Traffic Server caches response from the server regardless of the -``no-store`` headers from client requests. +Likewise, by default Traffic Server also ignores client ``Cache-Control: +no-store`` directives. Traffic Server caches response from the server regardless +of the ``no-store`` headers from client requests. -You can configure Traffic Server to honor both client directives with the -following: +You can configure Traffic Server to honor both of these client directives with +the following: #. Edit :ts:cv:`proxy.config.http.cache.ignore_client_no_cache` in :file:`records.config`. :: @@ -563,6 +563,12 @@ You can reconfigure Traffic Server to: - Cache all cookied content except text type. + It may be approprite to configure Traffic Server to not cache cookied text + content because object headers are stored along with the object, and + personalized cookie header values could be saved with the object. With + non-text objects, it is unlikely that personalized headers are delivered or + used. + To configure how Traffic Server caches cookied content: #. Edit :ts:cv:`proxy.config.http.cache.cache_responses_to_cookies` in From f3634931ac5da9606e49e8e8fde4b6037e7dc077 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 23:08:56 +0000 Subject: [PATCH 5/8] added testrun descriptions; added delay in the replay files --- tests/gold_tests/cache/cache-auth.test.py | 6 ++++-- tests/gold_tests/cache/cache-control.test.py | 10 +++++---- tests/gold_tests/cache/cache-cookie.test.py | 14 ++++++++----- .../cache/replay/auth-default.replay.yaml | 3 +++ .../cache/replay/auth-ignored.replay.yaml | 3 +++ .../cookie-all-but-text-with-excp.replay.yaml | 21 +++++++++++++++++++ .../replay/cookie-all-but-text.replay.yaml | 18 ++++++++++++++++ .../replay/cookie-bypass-cache.replay.yaml | 12 +++++++++++ .../replay/cookie-cache-img-only.replay.yaml | 12 +++++++++++ .../cache/replay/cookie-default.replay.yaml | 12 +++++++++++ .../request-cache-control-default.replay.yaml | 6 ++++++ ...est-cache-control-honor-client.replay.yaml | 6 ++++++ ...response-cache-control-default.replay.yaml | 6 ++++++ ...response-cache-control-ignored.replay.yaml | 6 ++++++ 14 files changed, 124 insertions(+), 11 deletions(-) diff --git a/tests/gold_tests/cache/cache-auth.test.py b/tests/gold_tests/cache/cache-auth.test.py index 4178fdd2f7e..51cd94af9c1 100644 --- a/tests/gold_tests/cache/cache-auth.test.py +++ b/tests/gold_tests/cache/cache-auth.test.py @@ -57,7 +57,8 @@ def setupTS(self): "Verify ATS doesn't store the response with WWW-Authenticate.") def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the proper caching behavior for request/response containing auth-related fields when ATS is in default configuration") tr.AddVerifierClientProcess( "auth-default-client", self.authDefaultReplayFile, @@ -103,7 +104,8 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the proper caching behavior for request/response containing auth-related fields when ATS is configured to bypass caching for those") tr.AddVerifierClientProcess( "auth-ignored-client", self.authIgnoredReplayFile, diff --git a/tests/gold_tests/cache/cache-control.test.py b/tests/gold_tests/cache/cache-control.test.py index 1bab4be38f8..5b4fe9ca36e 100644 --- a/tests/gold_tests/cache/cache-control.test.py +++ b/tests/gold_tests/cache/cache-control.test.py @@ -171,7 +171,7 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun("Verify the proper handling of cache-control directives in requests in default configuration") tr.AddVerifierClientProcess( "request-cache-control-default-client", self.requestCacheControlReplayFile, @@ -225,7 +225,8 @@ def setupTS(self): "Verify that ATS honors the no-store.") def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the proper handling of cache-control directives in requests when ATS is configured to honor client's request to bypass the cache") tr.AddVerifierClientProcess( "request-cache-control-honor-client-client", self.requestCacheControlReplayFile, @@ -273,7 +274,7 @@ def setupTS(self): "Verify that ATS honors the no-cache(or no-store) in response and bypasses the cache.") def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun("Verify the proper handling of cache-control directives in responses in default configuration") tr.AddVerifierClientProcess( "response-cache-control-client-default", self.responseCacheControlReplayFile, @@ -322,7 +323,8 @@ def setupTS(self): "Verify that ATS ignores the no-cache(or no-store) in response and caches the responses despite their presence.") def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the proper handling of cache-control directives in responses when ATS is configured to ignore server's request to bypass the cache") tr.AddVerifierClientProcess( "response-cache-control-client-ignored", self.responseCacheControlReplayFile, diff --git a/tests/gold_tests/cache/cache-cookie.test.py b/tests/gold_tests/cache/cache-cookie.test.py index 2f879ae7972..7f51c9ca3d0 100644 --- a/tests/gold_tests/cache/cache-cookie.test.py +++ b/tests/gold_tests/cache/cache-cookie.test.py @@ -51,7 +51,7 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun("Verify the correct caching behavior when ATS is in default configuration") tr.AddVerifierClientProcess( "cookie-default-client", self.cookieDefaultReplayFile, @@ -96,7 +96,8 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the correct caching behavior when ATS is configured to not cache response to cookie for any content type") tr.AddVerifierClientProcess( "cookie-bypass-client", self.cookieBypassReplayFile, @@ -141,7 +142,8 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the correct caching behavior when ATS is configured to cache response to cookie only for image content type") tr.AddVerifierClientProcess( "cookie-img-only-client", self.cookieImgOnlyReplayFile, @@ -186,7 +188,8 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the correct caching behavior when ATS is configured to cache response to cookie for all but text types") tr.AddVerifierClientProcess( "cookie-all-but-text-client", self.cookieAllButTextReplayFile, @@ -233,7 +236,8 @@ def setupTS(self): ) def runTraffic(self): - tr = Test.AddTestRun() + tr = Test.AddTestRun( + "Verify the correct caching behavior when ATS is configured to cache all content types but text, but with a few exceptions for text types which would also be cached") tr.AddVerifierClientProcess( "cookie-all-but-text-with-excp-client", self.cookieAllButTextReplayFile, diff --git a/tests/gold_tests/cache/replay/auth-default.replay.yaml b/tests/gold_tests/cache/replay/auth-default.replay.yaml index deff6057ce6..d68cdffc502 100644 --- a/tests/gold_tests/cache/replay/auth-default.replay.yaml +++ b/tests/gold_tests/cache/replay/auth-default.replay.yaml @@ -47,6 +47,9 @@ sessions: # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/auth diff --git a/tests/gold_tests/cache/replay/auth-ignored.replay.yaml b/tests/gold_tests/cache/replay/auth-ignored.replay.yaml index aeb5932feba..b0361fffcc0 100644 --- a/tests/gold_tests/cache/replay/auth-ignored.replay.yaml +++ b/tests/gold_tests/cache/replay/auth-ignored.replay.yaml @@ -46,6 +46,9 @@ sessions: status: 401 # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/auth diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml index 600502901e2..77cefbc47fe 100644 --- a/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml @@ -54,6 +54,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-img @@ -108,6 +111,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-vid @@ -162,6 +168,9 @@ sessions: # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-text @@ -216,6 +225,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/img @@ -270,6 +282,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/vid @@ -324,6 +339,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/text-response-no-set-cookie @@ -378,6 +396,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/text-response-has-cc-public diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml index 89f5d5a2a99..aa8a6e2a56a 100644 --- a/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml @@ -53,6 +53,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-img @@ -106,6 +109,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-vid @@ -160,6 +166,9 @@ sessions: # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-text @@ -214,6 +223,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-img @@ -268,6 +280,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-vid @@ -322,6 +337,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-text diff --git a/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml index decf4c43cda..eda11285549 100644 --- a/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml @@ -53,6 +53,9 @@ sessions: # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-text @@ -107,6 +110,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-img @@ -159,6 +165,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-text @@ -213,6 +222,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-img diff --git a/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml index 37f50cda5e2..2b377eb2322 100644 --- a/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml @@ -53,6 +53,9 @@ sessions: # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-text @@ -107,6 +110,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-img @@ -161,6 +167,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-text @@ -215,6 +224,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/cookie-img diff --git a/tests/gold_tests/cache/replay/cookie-default.replay.yaml b/tests/gold_tests/cache/replay/cookie-default.replay.yaml index d7e8aab6cb3..c9773bc5feb 100644 --- a/tests/gold_tests/cache/replay/cookie-default.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-default.replay.yaml @@ -53,6 +53,9 @@ sessions: # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-text @@ -107,6 +110,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/set-cookie-img @@ -160,6 +166,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/text @@ -214,6 +223,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the previous response was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cookie/img diff --git a/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml index 673c12e1b56..94d3bde4afe 100644 --- a/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml +++ b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml @@ -49,6 +49,9 @@ sessions: # Re-request and verify that Cache-Control: no-cache in the request is # ignored by making sure cached response was used - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/request-no-cache @@ -101,6 +104,9 @@ sessions: # Re-request to make sure the previous response was cached despite the # no-store directive in the previous request - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/request-no-store diff --git a/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml index f4f636d26de..9340ed66538 100644 --- a/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml +++ b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml @@ -50,6 +50,9 @@ sessions: # Re-request and verify that Cache-Control: no-cache in the request is # honored by making sure non-cached response was used - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/request-no-cache @@ -102,6 +105,9 @@ sessions: # Re-request and verify that Cache-Control: no-store in the previous # request is honored by making sure the previous response is not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/request-no-store diff --git a/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml index 04afc9a3c3b..b87ad86ad56 100644 --- a/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml +++ b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml @@ -51,6 +51,9 @@ sessions: # Re-request and make sure non-cached response is used, verifying that # Cache-Control: no-cache in the previous response is honored - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/response-no-cache @@ -101,6 +104,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure the response was not cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/response-no-store diff --git a/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml index 64f1433739e..2380e4a34de 100644 --- a/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml +++ b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml @@ -50,6 +50,9 @@ sessions: # Re-request and make sure cached response is used, verifying that # Cache-Control: no-cache in the response is ignored - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/response-no-cache @@ -101,6 +104,9 @@ sessions: - [Content-Length, { value: 4, as: equal }] # Re-request to make sure it was cached - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms method: "GET" version: "1.1" url: /cc/response-no-store From 2b2b94ef476f758ed688deb9ec1218ae13453501 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 23:17:18 +0000 Subject: [PATCH 6/8] skipping the failed test --- tests/gold_tests/cache/cache-control.test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/gold_tests/cache/cache-control.test.py b/tests/gold_tests/cache/cache-control.test.py index 5b4fe9ca36e..ebca08640fa 100644 --- a/tests/gold_tests/cache/cache-control.test.py +++ b/tests/gold_tests/cache/cache-control.test.py @@ -338,5 +338,5 @@ def runTraffic(self): def run(self): self.runTraffic() - -ResponseCacheControlIgnoredTest().run() +# Commenting out as this test would fail due to issue #9283 +# ResponseCacheControlIgnoredTest().run() From 651b4c4d6bd39c6d31fe63466f9d7560be429139 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Tue, 3 Jan 2023 23:25:37 +0000 Subject: [PATCH 7/8] Fixed typo --- doc/admin-guide/configuration/cache-basics.en.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/admin-guide/configuration/cache-basics.en.rst b/doc/admin-guide/configuration/cache-basics.en.rst index 148ac92aa70..273005b9b8d 100644 --- a/doc/admin-guide/configuration/cache-basics.en.rst +++ b/doc/admin-guide/configuration/cache-basics.en.rst @@ -563,7 +563,7 @@ You can reconfigure Traffic Server to: - Cache all cookied content except text type. - It may be approprite to configure Traffic Server to not cache cookied text + It may be appropriate to configure Traffic Server to not cache cookied text content because object headers are stored along with the object, and personalized cookie header values could be saved with the object. With non-text objects, it is unlikely that personalized headers are delivered or From acbdaf99fa9ce3f0ce20ac3a6003eeca11ea318f Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Thu, 5 Jan 2023 20:31:28 +0000 Subject: [PATCH 8/8] Update doc for ignore_client_no_cache and ignore_server_no_cache Make it clear that what ATS would ignore with ignore_client_no_cache and ignore_server_no_cache. --- doc/admin-guide/files/records.config.en.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index f3028148fc6..c9fcbfedd8e 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -2173,7 +2173,7 @@ Cache Control :reloadable: :overridable: - When enabled (``1``), |TS| ignores client requests to bypass the cache. + When enabled (``1``), |TS| ignores client requests to bypass the cache. Specifically, ``Pragma: no-cache``, ``Cache-Control: no-cache`` and ``Cache-Control: no-store`` in requests are ignored. .. ts:cv:: CONFIG proxy.config.http.cache.ims_on_client_no_cache INT 1 :reloadable: @@ -2185,7 +2185,7 @@ Cache Control :reloadable: :overridable: - When enabled (``1``), |TS| ignores origin server requests to bypass the cache. + When enabled (``1``), |TS| ignores origin server requests to bypass the cache. Specifically, ``Pragma: no-cache``, ``Cache-Control: no-cache`` and ``Cache-Control: no-store`` in responses are ignored. .. ts:cv:: CONFIG proxy.config.http.cache.cache_responses_to_cookies INT 1 :reloadable: