Browse Source

Fix error in WebFlux chapter on static resources

Issue: SPR-16864
pull/1836/head
Rossen Stoyanchev 8 years ago
parent
commit
eed663ff7e
  1. 13
      src/docs/asciidoc/web/webflux.adoc

13
src/docs/asciidoc/web/webflux.adoc

@ -2866,7 +2866,7 @@ evaluated and if present a `304` status code is returned.
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**") registry.addResourceHandler("/resources/**")
.addResourceLocations("/public", "classpath:/static/") .addResourceLocations("/public", "classpath:/static/")
.setCachePeriod(31556926); .setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS));
} }
} }
@ -2910,13 +2910,12 @@ so it can be injected into others.
Unlike Spring MVC at present in WebFlux there is no way to transparently rewrite static Unlike Spring MVC at present in WebFlux there is no way to transparently rewrite static
resource URLs since there are no view technologies that can make use of a non-blocking chain resource URLs since there are no view technologies that can make use of a non-blocking chain
of resolvers and transformers (e.g. resources on Amazon S3). When serving only local of resolvers and transformers. When serving only local resources the workaround is to use
resources the workaround is to use `ResourceUrlProvider` directly (e.g. through a custom `ResourceUrlProvider` directly (e.g. through a custom tag) and block.
tag) and block for 0 seconds.
Note that when using both `EncodedResourceResolver` (e.g. for serving gzipped or brotli Note that when using both `EncodedResourceResolver` (e.g. Gzip, Brotli encoded) and
encoded resources) and `VersionedResourceResolver`, they must be registered in this order. `VersionedResourceResolver`, they must be registered in that order to ensure content
That ensures content based versions are always computed reliably based on the unencoded file. based versions are always computed reliably based on the unencoded file.
http://www.webjars.org/documentation[WebJars] is also supported via `WebJarsResourceResolver` http://www.webjars.org/documentation[WebJars] is also supported via `WebJarsResourceResolver`
and automatically registered when `"org.webjars:webjars-locator"` is present on the and automatically registered when `"org.webjars:webjars-locator"` is present on the

Loading…
Cancel
Save