public class AppCacheManifestTransformer extends ResourceTransformerSupport
ResourceTransformer
implementation that helps handling resources
within HTML5 AppCache manifests for HTML5 offline applications.
This transformer:
ResourceResolver
strategies
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 "text/manifest"
content type,
it is required to configure it with
contentNegotiationConfigurer.mediaType("appcache", MediaType.valueOf("text/manifest")
in a WebMvcConfigurer
.
Constructor and Description |
---|
AppCacheManifestTransformer()
Create an AppCacheResourceTransformer that transforms files with extension ".appcache".
|
AppCacheManifestTransformer(String fileExtension)
Create an AppCacheResourceTransformer that transforms files with the extension
given as a parameter.
|
Modifier and Type | Method and Description |
---|---|
Resource |
transform(HttpServletRequest request,
Resource resource,
ResourceTransformerChain chain)
Transform the given resource.
|
getResourceUrlProvider, resolveUrlPath, setResourceUrlProvider, toAbsolutePath
public AppCacheManifestTransformer()
public AppCacheManifestTransformer(String fileExtension)
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain chain) throws IOException
ResourceTransformer
request
- the current requestresource
- the resource to transformchain
- the chain of remaining transformers to delegate tonull
)IOException
- if the transformation fails