htmlspring-mvcmanifestoffline-browsing

SpringMVC generated manifest xml Manifest fetch failed (406)


I'm generating a html5 cache manifest xml on the server side and I get Application Cache Error event: Manifest fetch failed (406) this error message is in my console.

I have this tag in my html:

<html manifest="http://localhost:8080/test/api/view/view/system/manifest">

My controller method:

@RequestMapping(value = "manifest", produces = "text/cache-manifest", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String manifest() {
    logger.debug("Generating the manifest file!");

    StringBuilder strManiFstBuilder = new StringBuilder();
    strManiFstBuilder.append("CACHE MANIFEST"); 
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("#revision 1");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("CACHE:");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("api/view/view/order");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("NETWORK:");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("api/view/view/system/ping");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("*");
    strManiFstBuilder.append("\n");

    return strManiFstBuilder.toString();
}

I have this in my web.xml

<mime-mapping>
    <extension>manifest</extension> 
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>

If I call the controller method from the browser this is generated:

CACHE MANIFEST

CACHE: api/view/bestellijstsearchlistview/order/search/template/tags,name,%20customer.naam,orderParts.orderItems.product.description,orderParts.orderItems.product.externalId/page/1/size/500 NETWORK: api/view/view/system/ping *

I have to generate this file how can I do that and what can be the problem with my solution?


Solution

  • I managed to fix this issue by removed the produces attribute from the annotations and I added the .manifest to the urlname.

    The header of my controller:

    @RequestMapping(value = "cache.manifest", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    @ResponseBody
    public String manifest() {
    
    
    <html manifest="http://localhost:8080/system/cache.manifest">