|
|
|
|
@ -77,6 +77,8 @@ public class CacheControl {
@@ -77,6 +77,8 @@ public class CacheControl {
|
|
|
|
|
@Nullable |
|
|
|
|
private Duration sMaxAge; |
|
|
|
|
|
|
|
|
|
private boolean immutable = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create an empty CacheControl instance. |
|
|
|
|
@ -320,6 +322,18 @@ public class CacheControl {
@@ -320,6 +322,18 @@ public class CacheControl {
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Add an "immutable" directive. |
|
|
|
|
* <p>This directive indicates that the origin server will not update the |
|
|
|
|
* representation of that resource during the freshness lifetime of the response. |
|
|
|
|
* @return {@code this}, to facilitate method chaining |
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc8246">rfc8246</a> |
|
|
|
|
*/ |
|
|
|
|
public CacheControl immutable() { |
|
|
|
|
this.immutable = true; |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the "Cache-Control" header value, if any. |
|
|
|
|
* @return the header value, or {@code null} if no directive was added |
|
|
|
|
@ -369,6 +383,9 @@ public class CacheControl {
@@ -369,6 +383,9 @@ public class CacheControl {
|
|
|
|
|
if (this.staleWhileRevalidate != null) { |
|
|
|
|
appendDirective(headerValue, "stale-while-revalidate=" + this.staleWhileRevalidate.getSeconds()); |
|
|
|
|
} |
|
|
|
|
if (this.immutable) { |
|
|
|
|
appendDirective(headerValue, "immutable"); |
|
|
|
|
} |
|
|
|
|
return headerValue.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|