Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EXPIRES HTTP header from cache #3515

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public ResponseCacheManager(CacheKeyGenerator cacheKeyGenerator, Cache cache, Du
this.ignoreNoCacheUpdate = isSkipNoCacheUpdateActive(requestOptions);
this.afterCacheExchangeMutators = List.of(new SetResponseHeadersAfterCacheExchangeMutator(),
new SetStatusCodeAfterCacheExchangeMutator(),
new RemoveHeadersAfterCacheExchangeMutator(HttpHeaders.PRAGMA),
new RemoveHeadersAfterCacheExchangeMutator(HttpHeaders.PRAGMA, HttpHeaders.EXPIRES),
new SetMaxAgeHeaderAfterCacheExchangeMutator(configuredTimeToLive, Clock.systemDefaultZone(),
ignoreNoCacheUpdate),
new SetCacheDirectivesByMaxAgeAfterCacheExchangeMutator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,30 @@ void shouldNotCacheWhenAuthorizationHeaderIsDifferent() {

@Test
void shouldNotReturnPragmaHeaderInNonCachedAndCachedResponses() {
shouldNotReturnHeader(HttpHeaders.PRAGMA);
}

@Test
void shouldNotReturnExpiresHeaderInNonCachedAndCachedResponses() {
shouldNotReturnHeader(HttpHeaders.EXPIRES);
}

private void shouldNotReturnHeader(String header) {
String uri = "/" + UUID.randomUUID() + "/cache/headers";

testClient.get()
.uri(uri)
.header("Host", "www.localresponsecache.org")
.exchange()
.expectHeader()
.doesNotExist(HttpHeaders.PRAGMA);
.doesNotExist(header);

testClient.get()
.uri(uri)
.header("Host", "www.localresponsecache.org")
.exchange()
.expectHeader()
.doesNotExist(HttpHeaders.PRAGMA);
.doesNotExist(header);
}

void assertNonVaryHeaderInContent(String uri, String varyHeader, String varyHeaderValue, String nonVaryHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,30 @@ void shouldGlobalCacheResponseWhenRouteDoesNotHaveFilter() {

@Test
void shouldNotReturnPragmaHeaderInNonCachedAndCachedResponses() {
shouldNotReturnHeader(HttpHeaders.PRAGMA);
}

@Test
void shouldNotReturnExpiresHeaderInNonCachedAndCachedResponses() {
shouldNotReturnHeader(HttpHeaders.EXPIRES);
}

private void shouldNotReturnHeader(String header) {
String uri = "/" + UUID.randomUUID() + "/global-cache/headers";

testClient.get()
.uri(uri)
.header("Host", "www.localresponsecache.org")
.exchange()
.expectHeader()
.doesNotExist(HttpHeaders.PRAGMA);
.doesNotExist(header);

testClient.get()
.uri(uri)
.header("Host", "www.localresponsecache.org")
.exchange()
.expectHeader()
.doesNotExist(HttpHeaders.PRAGMA);
.doesNotExist(header);
}

@EnableAutoConfiguration
Expand Down
Loading