Interface HttpCacheConfig
@ProviderType
public interface HttpCacheConfig
Configuration for Http cache. Multiple configs can be supplied. Request uri, authentication details, cache store
details and invalidation JCR path details are captured through configs. Developer hook supplied for extension of
cache config via
HttpCacheConfigExtension-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(org.apache.sling.api.SlingHttpServletRequest request) Determine if this cache config is applicable for the given request.booleanacceptsRule(String servicePid) Check if the cache config accepts the service pid of the cache handling rule.buildCacheKey(String resourcePath) Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.buildCacheKey(org.apache.sling.api.SlingHttpServletRequest request) Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.booleancanInvalidate(String path) Determines if a JCR path is a candidate for invalidating this cache.Get the authentication requirement for request set for this config.Get the configured list of blacklisted request URIs.Name of the configured cache store.Get a list of excluded cookie keys (simple string) of cookies that should NOT be put in the cached response, to be served to the output.Get a list of headers (as regex pattern) that should NOT be put in the cached response, to be served to the output.default longGets the expiry time for the cache entry access / read.default longGets the expiry time for the cache entry updated.default longReturns a custom expiry for this config in miliseconds.Get the configured list of JCR paths that could unvalidate this config.intgetOrder()Gets the order the HttpCacheConfig should be executed in.Get the configured list of whitelisted request URIs.booleanisValid()booleanReturns true if the key is generated using this cache config.
-
Method Details
-
getCacheStoreName
String getCacheStoreName()Name of the configured cache store.- Returns:
-
getAuthenticationRequirement
String getAuthenticationRequirement()Get the authentication requirement for request set for this config.- Returns:
- Uses the constants defined in
AuthenticationStatusConfigConstants
-
getRequestUriPatterns
Get the configured list of whitelisted request URIs.- Returns:
-
getBlacklistedRequestUriPatterns
Get the configured list of blacklisted request URIs.- Returns:
-
getJCRInvalidationPathPatterns
Get the configured list of JCR paths that could unvalidate this config.- Returns:
-
getExcludedResponseHeaderPatterns
Get a list of headers (as regex pattern) that should NOT be put in the cached response, to be served to the output.- Returns:
-
getExcludedCookieKeys
Get a list of excluded cookie keys (simple string) of cookies that should NOT be put in the cached response, to be served to the output. This is useful for example with systems that put a login cookie in each response.- Returns:
-
accepts
boolean accepts(org.apache.sling.api.SlingHttpServletRequest request) throws HttpCacheRepositoryAccessException Determine if this cache config is applicable for the given request. CallsHttpCacheConfigExtension .accept()for providing share of control to the custom code.- Parameters:
request- the request- Returns:
- true if the response should be cached, false if it should not be cached.
- Throws:
HttpCacheRepositoryAccessException
-
isValid
boolean isValid()- Returns:
- true if this config is considered valid and processable by the HttpCacheEngine.
-
buildCacheKey
CacheKey buildCacheKey(org.apache.sling.api.SlingHttpServletRequest request) throws HttpCacheKeyCreationException Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.- Parameters:
request- the request to create the CacheKey for- Returns:
- the CacheKey
- Throws:
HttpCacheKeyCreationException
-
buildCacheKey
Creates the CacheKey object using the CacheKeyFactory associated with this HttpCacheConfig factory instance.- Parameters:
resourcePath- the resourcePath associated with the Cache Key- Returns:
- the CacheKey
- Throws:
HttpCacheKeyCreationException
-
canInvalidate
Determines if a JCR path is a candidate for invalidating this cache.- Parameters:
path- the jcr path- Returns:
- true if this config can be invalidated by a change to this path
-
knows
Returns true if the key is generated using this cache config.- Parameters:
key-- Returns:
- Throws:
HttpCacheKeyCreationException
-
getOrder
int getOrder()Gets the order the HttpCacheConfig should be executed in.- Returns:
-
acceptsRule
Check if the cache config accepts the service pid of the cache handling rule.- Parameters:
servicePid- Service pid of HttpCacheHandlingRule.- Returns:
- True if it accepts.
-
getFilterScope
HttpCacheConfig.FilterScope getFilterScope()- Returns:
- the filter scope this HttpCacheConfig should involve itself in.
-
getExpiryOnCreate
default long getExpiryOnCreate()Returns a custom expiry for this config in miliseconds. -1 means the entry will never expire itself. 0 means the expiry is not set, and the default expiry will be used. 1 or above is the expiry for entries produced by this config .- Returns:
-
getExpiryForAccess
default long getExpiryForAccess()Gets the expiry time for the cache entry access / read. If set, it will refresh the expiry time when an entry is read with given value. Value is in miliseconds.- Returns:
- the expiry time
-
getExpiryForUpdate
default long getExpiryForUpdate()Gets the expiry time for the cache entry updated. If set, it will refresh the expiry time when an entry is updated with given value. Value is in miliseconds.- Returns:
- the expiry time
-