XML configuration support for RFC 5861
This commit adds the XML+XSD configuration part of the RFC 5861 Cache-Control directives added in Spring's `CacheControl`. Issue: SPR-13841
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -242,6 +242,14 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||
if (element.hasAttribute("s-maxage")) {
|
||||
cacheControl = cacheControl.sMaxAge(Long.parseLong(element.getAttribute("s-maxage")), TimeUnit.SECONDS);
|
||||
}
|
||||
if (element.hasAttribute("stale-while-revalidate")) {
|
||||
cacheControl = cacheControl.staleWhileRevalidate(
|
||||
Long.parseLong(element.getAttribute("stale-while-revalidate")), TimeUnit.SECONDS);
|
||||
}
|
||||
if (element.hasAttribute("stale-if-error")) {
|
||||
cacheControl = cacheControl.staleIfError(
|
||||
Long.parseLong(element.getAttribute("stale-if-error")), TimeUnit.SECONDS);
|
||||
}
|
||||
return cacheControl;
|
||||
}
|
||||
|
||||
|
||||
@@ -581,6 +581,22 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Adds a "s-maxage" directive in the Cache-Control header.
|
||||
This directive has the same meaning as the "max-age" directive, except it only applies to shared caches.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="stale-while-revalidate" type="xsd:int" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Adds a "stale-while-revalidate" directive in the Cache-Control header.
|
||||
This indicates that caches may serve the response after it becomes stale up to the given number of seconds.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="stale-if-error" type="xsd:int" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Adds a "s-maxage" directive in the Cache-Control header.
|
||||
This directive has the same meaning as the "max-age" directive, except it only applies to shared caches.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
Reference in New Issue
Block a user