Class CachingResourceResolver
java.lang.Object
org.springframework.web.servlet.resource.AbstractResourceResolver
org.springframework.web.servlet.resource.CachingResourceResolver
- All Implemented Interfaces:
- ResourceResolver
A 
ResourceResolver that
 resolves resources from a Cache or otherwise
 delegates to the resolver chain and saves the result in the cache.- Since:
- 4.1
- Author:
- Rossen Stoyanchev, Brian Clozel
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe prefix used for resolved resource cache keys.static final StringThe prefix used for resolved URL path cache keys.Fields inherited from class org.springframework.web.servlet.resource.AbstractResourceResolverlogger
- 
Constructor SummaryConstructorsConstructorDescriptionCachingResourceResolver(Cache cache) CachingResourceResolver(CacheManager cacheManager, String cacheName) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected StringcomputeKey(HttpServletRequest request, String requestPath) getCache()Return the configuredCache.Return a read-only list with the supported content codings.protected ResourceresolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) protected StringresolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) voidsetContentCodings(List<String> codings) Configure the supported content codings from the "Accept-Encoding" header for which to cache resource variations.Methods inherited from class org.springframework.web.servlet.resource.AbstractResourceResolverresolveResource, resolveUrlPath
- 
Field Details- 
RESOLVED_RESOURCE_CACHE_KEY_PREFIXThe prefix used for resolved resource cache keys.- See Also:
 
- 
RESOLVED_URL_PATH_CACHE_KEY_PREFIXThe prefix used for resolved URL path cache keys.- See Also:
 
 
- 
- 
Constructor Details- 
CachingResourceResolver
- 
CachingResourceResolver
 
- 
- 
Method Details- 
getCacheReturn the configuredCache.
- 
setContentCodingsConfigure the supported content codings from the "Accept-Encoding" header for which to cache resource variations.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.- Parameters:
- codings- one or more supported content codings
- Since:
- 5.1
 
- 
getContentCodingsReturn a read-only list with the supported content codings.- Since:
- 5.1
 
- 
resolveResourceInternalprotected Resource resolveResourceInternal(@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) - Specified by:
- resolveResourceInternalin class- AbstractResourceResolver
 
- 
computeKey
- 
resolveUrlPathInternalprotected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) - Specified by:
- resolveUrlPathInternalin class- AbstractResourceResolver
 
 
-