public class CachingResourceResolver extends AbstractResourceResolver
ResourceResolver
that
resolves resources from a Cache
or otherwise
delegates to the resolver chain and saves the result in the cache.Modifier and Type | Field and Description |
---|---|
static String |
RESOLVED_RESOURCE_CACHE_KEY_PREFIX
The prefix used for resolved resource cache keys.
|
static String |
RESOLVED_URL_PATH_CACHE_KEY_PREFIX
The prefix used for resolved URL path cache keys.
|
logger
Constructor and Description |
---|
CachingResourceResolver(Cache cache) |
CachingResourceResolver(CacheManager cacheManager,
String cacheName) |
Modifier and Type | Method and Description |
---|---|
protected String |
computeKey(HttpServletRequest request,
String requestPath) |
Cache |
getCache()
Return the configured
Cache . |
List<String> |
getContentCodings()
Return a read-only list with the supported content codings.
|
protected Resource |
resolveResourceInternal(HttpServletRequest request,
String requestPath,
List<? extends Resource> locations,
ResourceResolverChain chain) |
protected String |
resolveUrlPathInternal(String resourceUrlPath,
List<? extends Resource> locations,
ResourceResolverChain chain) |
void |
setContentCodings(List<String> codings)
Configure the supported content codings from the
"Accept-Encoding" header for which to cache resource variations.
|
resolveResource, resolveUrlPath
public static final String RESOLVED_RESOURCE_CACHE_KEY_PREFIX
public static final String RESOLVED_URL_PATH_CACHE_KEY_PREFIX
public CachingResourceResolver(Cache cache)
public CachingResourceResolver(CacheManager cacheManager, String cacheName)
public Cache getCache()
Cache
.public void setContentCodings(List<String> codings)
The codings configured here are generally expected to match those
configured on EncodedResourceResolver.setContentCodings(List)
.
By default this property is set to ["br", "gzip"] based on
the value of EncodedResourceResolver.DEFAULT_CODINGS
.
codings
- one or more supported content codingspublic List<String> getContentCodings()
protected Resource resolveResourceInternal(@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)
resolveResourceInternal
in class AbstractResourceResolver
protected String computeKey(@Nullable HttpServletRequest request, String requestPath)
protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain)
resolveUrlPathInternal
in class AbstractResourceResolver