From 084daa7fb510cdc650b0ade942c2fc067d2b2027 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 16 Sep 2016 12:04:56 +0200 Subject: [PATCH] Document media type registration for appcache files Since appcache manifests can have various file extensions, developers should register the (file extension, media type) mapping in their Spring MVC / Reactive Web configuration. This commit adds javadoc on both `AppCacheManifestTransformer` variants to explain how to do that. Issue: SPR-14510 --- .../resource/AppCacheManifestTransformer.java | 13 ++++++++----- .../resource/AppCacheManifestTransformer.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java index 113cf4d286d..6d500ed9725 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/AppCacheManifestTransformer.java @@ -53,13 +53,16 @@ import org.springframework.web.server.ServerWebExchange; * of the manifest in order to trigger an appcache reload in the browser. * * - * All files that have the ".appcache" file extension, or the extension given - * in the constructor, will be transformed by this class. - * - *

This hash is computed using the content of the appcache manifest and the - * content of the linked resources; so changing a resource linked in the manifest + *

All files that have the ".appcache" file extension, or the extension given in the constructor, + * will be transformed by this class. This hash is computed using the content of the appcache manifest + * and the content of the linked resources; so changing a resource linked in the manifest * or the manifest itself should invalidate the browser cache. * + *

In order to serve manifest files with the proper {@code "text/manifest"} content type, + * it is required to configure it with + * {@code requestedContentTypeResolverBuilder.mediaType("appcache", MediaType.valueOf("text/manifest")} + * in {@code WebReactiveConfiguration.configureRequestedContentTypeResolver()}. + * * @author Rossen Stoyanchev * @author Brian Clozel * @since 5.0 diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index 4e23f9adb1a..daee253997f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -47,11 +47,15 @@ import org.springframework.util.StringUtils; * thus changing the content of the manifest in order to trigger an appcache reload in the browser. * * - * All files that have the ".appcache" file extension, or the extension given in the constructor, - * will be transformed by this class. + *

All files that have the ".appcache" file extension, or the extension given in the constructor, + * will be transformed by this class. This hash is computed using the content of the appcache manifest + * and the content of the linked resources; so changing a resource linked in the manifest + * or the manifest itself should invalidate the browser cache. * - *

This hash is computed using the content of the appcache manifest and the content of the linked resources; - * so changing a resource linked in the manifest or the manifest itself should invalidate the browser cache. + *

In order to serve manifest files with the proper {@code "text/manifest"} content type, + * it is required to configure it with + * {@code contentNegotiationConfigurer.mediaType("appcache", MediaType.valueOf("text/manifest")} + * in a {@code WebMvcConfigurerAdapter}. * * @author Brian Clozel * @since 4.1