Add RFC-5681 support to CacheControl

This commit adds the "stale-while-revalidate" and "stale-if-error"
Cache-Control directives in the `CacheControl` support class.

Issue: SPR-13841
This commit is contained in:
madorb
2016-01-05 11:05:09 -06:00
committed by Brian Clozel
parent d681f77d62
commit 6c282096c6
2 changed files with 54 additions and 0 deletions

View File

@@ -63,4 +63,17 @@ public class CacheControlTests {
CacheControl cc = CacheControl.noStore();
assertThat(cc.getHeaderValue(), Matchers.equalTo("no-store"));
}
@Test
public void staleIfError() throws Exception {
CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS).staleIfError(2, TimeUnit.HOURS);
assertThat(cc.getHeaderValue(), Matchers.equalTo("max-age=3600, stale-if-error=7200"));
}
@Test
public void staleWhileRevalidate() throws Exception {
CacheControl cc = CacheControl.maxAge(1, TimeUnit.HOURS).staleWhileRevalidate(2, TimeUnit.HOURS);
assertThat(cc.getHeaderValue(), Matchers.equalTo("max-age=3600, stale-while-revalidate=7200"));
}
}