Package org.jgrapes.http
Class ResponseCreationSupport.DefaultMaxAgeCalculator
java.lang.Object
org.jgrapes.http.ResponseCreationSupport.DefaultMaxAgeCalculator
- All Implemented Interfaces:
ResponseCreationSupport.MaxAgeCalculator
- Enclosing class:
ResponseCreationSupport
public static class ResponseCreationSupport.DefaultMaxAgeCalculator
extends Object
implements ResponseCreationSupport.MaxAgeCalculator
DefaultMaxAgeCalculator provides an implementation that
tries to guess a good max age value by looking at the
path of the requested resource.
If the path contains the pattern “dash, followed by a number, followed by a dot and a number” it is assumed that the resource is versioned, i.e. its path changes if the resource changes. In this case a max age of one year is returned. In all other cases, a max age value of 60 (one minute) is returned.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
maxAge
(HttpRequest request, MediaType mediaType) Calculate a max age value for a response using the given request and the media type of the repsonse.
-
Field Details
-
VERSION_PATTERN
-
-
Constructor Details
-
DefaultMaxAgeCalculator
public DefaultMaxAgeCalculator()
-
-
Method Details
-
maxAge
Description copied from interface:ResponseCreationSupport.MaxAgeCalculator
Calculate a max age value for a response using the given request and the media type of the repsonse.- Specified by:
maxAge
in interfaceResponseCreationSupport.MaxAgeCalculator
- Parameters:
request
- the request, usually only the URI is considered for the calculationmediaType
- the media type of the response- Returns:
- the max age value to be used in the response
-