Correct LocalResponseCache behaviour w/ "no-cache", "must-revalidate", "max-age" and "no-store" directives
summary:
1. Inputs / expected result in order assuming Cache TTL configured to 120s
* Request contains `no-store` or `private`
* (done) Cache is skipped without storing response and `Cache-Control` will come from upstream
* Request contains `no-cache`
* The cached response is ignored by SCG dispatching to upstream(we cannot return 304 - imagine a client sends no-cache waiting for the server to revalidate and returns fresh data but instead it receives a bodyless response 304)
* A) Fresh response coming from upstream is renewed in the SCG cache and `Cache-Control: max-age=120s`. Other clients will see max-age increased
* B) Fresh response coming from upstream is not stored. Other clients will not be affected.
* Otherwise (ignoring `ETag`, `If-Modified-Since` and other request directives
* if Response is not cached in SCG yet
* `Cache-Control: max-age=120` (no-cache, no-store and must-revalidate doesn't make sense)
* if Response is cached in SCG with remaining TTL = 30s
* `Cache-Control: max-age=30` (no-cache, no-store and must-revalidate doesn't make sense)
* if Response is cached in SCG with remaining TTL = 0s
* `Cache-Control: max-age=0,no-cache,must-revalidate` (max-age=0+must-revalidate is equivalent to no-cache)
2. Revalidation is out of scope but it can be added in the future (ETag, If-Modified-Since, Modified-Since)
This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 6, Spring Boot 3 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
@ -109,7 +109,7 @@ from the `file` menu.
@@ -109,7 +109,7 @@ from the `file` menu.
== Contributing
:spring-cloud-build-branch: 4.0.x
:spring-cloud-build-branch: master
Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
@ -126,7 +126,7 @@ author credit if we do. Active contributors might be asked to join the core tea
@@ -126,7 +126,7 @@ author credit if we do. Active contributors might be asked to join the core tea
given the ability to merge pull requests.
=== Code of Conduct
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/{spring-cloud-build-branch}/docs/src/main/asciidoc/code-of-conduct.adoc[code of
conduct]. By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.
@ -137,7 +137,7 @@ added after the original pull request but before a merge.
@@ -137,7 +137,7 @@ added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
@ -41,9 +41,9 @@ public class GlobalLocalResponseCacheGatewayFilter implements GlobalFilter, Orde
@@ -41,9 +41,9 @@ public class GlobalLocalResponseCacheGatewayFilter implements GlobalFilter, Orde
@ -45,25 +47,33 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@@ -45,25 +47,33 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@ -77,10 +87,10 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@@ -77,10 +87,10 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@ -92,11 +102,17 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@@ -92,11 +102,17 @@ public class SetMaxAgeHeaderAfterCacheExchangeMutator implements AfterCacheExcha
@ -101,17 +114,18 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@@ -101,17 +114,18 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@ -163,11 +177,13 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@@ -163,11 +177,13 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@ -213,17 +229,6 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@@ -213,17 +229,6 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@ -275,34 +280,186 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe
@@ -275,34 +280,186 @@ public class LocalResponseCacheGatewayFilterFactoryTests extends BaseWebClientTe