private static final Log log = LogFactory.getLog(ExpiresFilter.class);
- private static final String PARAMETER_EXPIRES_ACTIVE = "ExpiresActive";
-
private static final String PARAMETER_EXPIRES_BY_TYPE = "ExpiresByType";
private static final String PARAMETER_EXPIRES_DEFAULT = "ExpiresDefault";
}
/**
- * @see #isActive()
- */
- private boolean active = true;
-
- /**
* Default Expires configuration.
*/
private ExpiresConfiguration defaultExpiresConfiguration;
httpRequest.getRequestURL()));
}
chain.doFilter(request, response);
- } else if (active) {
+ } else {
XHttpServletResponse xResponse = new XHttpServletResponse(
httpRequest, httpResponse);
chain.doFilter(request, xResponse);
// onBeforeWriteResponseBody()
onBeforeWriteResponseBody(httpRequest, xResponse);
}
- } else {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("expiresFilter.filterNotActive",
- httpRequest.getRequestURL()));
- }
- chain.doFilter(request, response);
}
} else {
chain.doFilter(request, response);
} else if (name.equalsIgnoreCase(PARAMETER_EXPIRES_DEFAULT)) {
ExpiresConfiguration expiresConfiguration = parseExpiresConfiguration(value);
this.defaultExpiresConfiguration = expiresConfiguration;
- } else if (name.equalsIgnoreCase(PARAMETER_EXPIRES_ACTIVE)) {
- this.active = "On".equalsIgnoreCase(value) ||
- Boolean.valueOf(value).booleanValue();
} else if (name.equalsIgnoreCase(PARAMETER_EXPIRES_EXCLUDED_RESPONSE_STATUS_CODES)) {
this.excludedResponseStatusCodes = commaDelimitedListToIntArray(value);
} else {
}
/**
- * Indicates that the filter is active. If <code>false</code>, the filter is
- * pass-through. Default is <code>true</code>.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
*
* <p>
* <code>protected</code> for extension.
return new ExpiresConfiguration(startingPoint, durations);
}
- public void setActive(boolean active) {
- this.active = active;
- }
-
public void setDefaultExpiresConfiguration(
ExpiresConfiguration defaultExpiresConfiguration) {
this.defaultExpiresConfiguration = defaultExpiresConfiguration;
@Override
public String toString() {
- return getClass().getSimpleName() + "[active=" + this.active +
- ", excludedResponseStatusCode=[" +
+ return getClass().getSimpleName() + "[excludedResponseStatusCode=[" +
intsToCommaDelimitedString(this.excludedResponseStatusCodes) +
"], default=" + this.defaultExpiresConfiguration + ", byType=" +
this.expiresConfigurationByContentType + "]";
expiresFilter.startingPointNotFound=Starting point (access|now|modification|a<seconds>|m<seconds>) not found in directive "{0}"
expiresFilter.startingPointInvalid=Invalid starting point (access|now|modification|a<seconds>|m<seconds>) "{0}" in directive "{1}"
expiresFilter.responseAlreadyCommited=Request "{0}", can not apply ExpiresFilter on already committed response.
-expiresFilter.filterNotActive=Request "{0}", ExpiresFilter is NOT active
expiresFilter.noExpirationConfiguredForContentType=No Expires configuration found for content-type "{0}"
expiresFilter.useMatchingConfiguration=Use {0} matching "{1}" for content-type "{2}" returns {3}
expiresFilter.useDefaultConfiguration=Use default {0} for content-type "{1}" returns {2}
<attributes>
- <attribute name="ExpiresActive" required="false">
- <p>
- This directive enables or disables the generation of the <tt>Expires</tt> and
- <tt>Cache-Control</tt> headers by this <tt>ExpiresFilter</tt>. If set to
- <tt>Off</tt>, the headers will not be generated for any HTTP response. If set
- to <tt>On</tt> or <tt>true</tt>, the headers will be added to served HTTP
- responses according to the criteria defined by the
- <tt>ExpiresByType <content-type></tt> and <tt>ExpiresDefault</tt>
- directives. Note that this directive does not guarantee that an
- <tt>Expires</tt> or <tt>Cache-Control</tt> header will be generated. If the
- criteria aren't met, no header will be sent, and the effect will be as
- though this directive wasn't even specified.
- </p>
- <p>
- Default value is <tt>true</tt>.
- </p>
-
- <p>
- <i>Sample: enable filter</i>
- </p>
-
- <source>
-<init-param>
- <!-- supports case insensitive 'On' or 'true' -->
- <param-name>ExpiresActive</param-name>
- <param-value>On</param-value>
-</init-param>
- </source>
- <p>
- <i>Sample: disable filter</i>
- </p>
-
- <source>
-<init-param>
- <!-- supports anything different from case insensitive 'On' and 'true' -->
- <param-name>ExpiresActive</param-name>
- <param-value>Off</param-value>
-</init-param>
- </source>
- </attribute>
-
<attribute name="ExpiresExcludedResponseStatusCodes" required="false">
<p>
This directive defines the http response status codes for which the