Add AppCacheResourceTransformer

This change adds a new ResourceTransformer that helps handling resources
within HTML5 AppCache manifests for HTML5 offline application.

This transformer:
* modifies links to match the public URL paths
* appends a comment in the manifest, containing a Hash (e.g. "# Hash:
9de0f09ed7caf84e885f1f0f11c7e326")

See http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline
for more details on HTML5 offline apps and appcache manifests.

Here is a WebConfig example:

  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {

    AppCacheResourceTransformer appCacheTransformer =
          new AppCacheResourceTransformer();

      registry.addResourceHandler("/**")
          .addResourceLocations("classpath:static/")
          .setResourceResolvers(...)
          .setResourceTransformers(..., appCacheTransformer);
  }

Issue: SPR-11964
This commit is contained in:
Brian Clozel
2014-07-10 16:55:25 +02:00
parent 2bd6e24b65
commit f11815c960
4 changed files with 359 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
CACHE MANIFEST
# this is a comment
CACHE:
bar.css
foo.css
//example.org/style.css
NETWORK:
*
CACHE:
js/bar.js
http://example.org/image.png
FALLBACK:
/main /static.html

View File

@@ -0,0 +1,4 @@
THIS DOES NOT START WITH "CACHE MANIFEST"
CACHE:
bar.css