Skip to content

Commit 1943a1f

Browse files
committed
Fix error in WebFlux chapter on static resources
Issue: SPR-16864
1 parent a158ff4 commit 1943a1f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/docs/asciidoc/web/webflux.adoc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ evaluated and if present a `304` status code is returned.
28682868
public void addResourceHandlers(ResourceHandlerRegistry registry) {
28692869
registry.addResourceHandler("/resources/**")
28702870
.addResourceLocations("/public", "classpath:/static/")
2871-
.setCachePeriod(31556926);
2871+
.setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS));
28722872
}
28732873
28742874
}
@@ -2912,9 +2912,12 @@ so it can be injected into others.
29122912

29132913
Unlike Spring MVC at present in WebFlux there is no way to transparently rewrite static
29142914
resource URLs since there are no view technologies that can make use of a non-blocking chain
2915-
of resolvers and transformers (e.g. resources on Amazon S3). When serving only local
2916-
resources the workaround is to use `ResourceUrlProvider` directly (e.g. through a custom
2917-
tag) and block for 0 seconds.
2915+
of resolvers and transformers. When serving only local resources the workaround is to use
2916+
`ResourceUrlProvider` directly (e.g. through a custom tag) and block.
2917+
2918+
Note that when using both `GzipResourceResolver` and `VersionedResourceResolver`, they must
2919+
be registered in that order to ensure content based versions are always computed reliably
2920+
based on the unencoded file.
29182921

29192922
http://www.webjars.org/documentation[WebJars] is also supported via `WebJarsResourceResolver`
29202923
and automatically registered when `"org.webjars:webjars-locator"` is present on the

0 commit comments

Comments
 (0)