org.springframework.web.reactive.resource

## Class CachingResourceResolver

- java.lang.Object
- - org.springframework.web.reactive.resource.AbstractResourceResolver
  - - org.springframework.web.reactive.resource.CachingResourceResolver

All Implemented Interfaces:
  ResourceResolver

    public class CachingResourceResolver
    extends AbstractResourceResolver

A `ResourceResolver` that resolves resources from a `Cache` or otherwise delegates to the resolver chain and caches the result.

Since:
  5.0
Author:
  Rossen Stoyanchev, Brian Clozel

### Field Summary

Fields
`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.

### Fields inherited from class org.springframework.web.reactive.resource.AbstractResourceResolver

`logger`

### Constructor Summary

Constructors
Constructor and Description
`CachingResourceResolver(org.springframework.cache.Cache cache)`
`CachingResourceResolver(org.springframework.cache.CacheManager cacheManager, String cacheName)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected String` `computeKey(org.springframework.web.server.ServerWebExchange exchange, String requestPath)`
`org.springframework.cache.Cache` `getCache()` Return the configured `Cache`.
`List<String>` `getContentCodings()` Return a read-only list with the supported content codings.
`protected reactor.core.publisher.Mono<org.springframework.core.io.Resource>` `resolveResourceInternal(org.springframework.web.server.ServerWebExchange exchange, String requestPath, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)`
`protected reactor.core.publisher.Mono<String>` `resolveUrlPathInternal(String resourceUrlPath, List<? extends org.springframework.core.io.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.

### Methods inherited from class org.springframework.web.reactive.resource.AbstractResourceResolver

`resolveResource, resolveUrlPath`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### RESOLVED_RESOURCE_CACHE_KEY_PREFIX

    public static final String RESOLVED_RESOURCE_CACHE_KEY_PREFIX

The prefix used for resolved resource cache keys.

See Also:
  Constant Field Values

#### RESOLVED_URL_PATH_CACHE_KEY_PREFIX

    public static final String RESOLVED_URL_PATH_CACHE_KEY_PREFIX

The prefix used for resolved URL path cache keys.

See Also:
  Constant Field Values

### Constructor Detail

#### CachingResourceResolver

    public CachingResourceResolver(org.springframework.cache.Cache cache)

#### CachingResourceResolver

    public CachingResourceResolver(org.springframework.cache.CacheManager cacheManager,
                                   String cacheName)

### Method Detail

#### getCache

    public org.springframework.cache.Cache getCache()

Return the configured `Cache`.

#### setContentCodings

    public void setContentCodings(List<String> codings)

Configure 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

#### getContentCodings

    public List<String> getContentCodings()

Return a read-only list with the supported content codings.

Since:
  5.1

#### resolveResourceInternal

    protected reactor.core.publisher.Mono<org.springframework.core.io.Resource> resolveResourceInternal(@Nullable
                                                                                                        org.springframework.web.server.ServerWebExchange exchange,
                                                                                                        String requestPath,
                                                                                                        List<? extends org.springframework.core.io.Resource> locations,
                                                                                                        ResourceResolverChain chain)

Specified by:
  `resolveResourceInternal` in class `AbstractResourceResolver`

#### computeKey

    protected String computeKey(@Nullable
                                org.springframework.web.server.ServerWebExchange exchange,
                                String requestPath)

#### resolveUrlPathInternal

    protected reactor.core.publisher.Mono<String> resolveUrlPathInternal(String resourceUrlPath,
                                                                         List<? extends org.springframework.core.io.Resource> locations,
                                                                         ResourceResolverChain chain)

Specified by:
  `resolveUrlPathInternal` in class `AbstractResourceResolver`