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(java.lang.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(java.lang.String fileExtension)
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain chain) throws java.io.IOException
ResourceTransformer
request
- the current requestresource
- the resource to transformchain
- the chain of remaining transformers to delegate tonull
)java.io.IOException
- if the transformation fails