MVC Dynamic Appcache Manifest and Google Chrome “Application Cache Error event: Manifest changed during update”

For MVC, dynamically generate a manifest for appcache has another common problem:

Problem:

You have an AppManifestController and you have a view.

   1: @{

   2:     Layout = null;

   3:     HttpContext.Current.Response.ContentType = "text/cache-manifest";

   4:     

   5:     // must write out explicitly or else the first line will be empty, making the cache manifest not parseable by browser.

   6:     Response.Write("CACHE MANIFEST");

   7: }

   8: # Generated: @DateTime.Now.ToString()

   9:  

  10: ...

Google chrome will give the error message “Application Cache Error event: Manifest changed during update

Cause:

Google seems to get the appcache manifest twice.  The use of @DateTime.Now.ToString() means each request will get a slightly different manifest due to the different time.  And  Chrome chokes on that.

Solution

Just don’t do it; comment it out.  You don’t need that line.  If you are trying to expire the manifest, use other approaches.

   1: @{

   2:     Layout = null;

   3:     HttpContext.Current.Response.ContentType = "text/cache-manifest";

   4:     // must write out explicitly or else the first line will be empty, making the cache manifest not parseable by browser.

   5:     Response.Write("CACHE MANIFEST");

   6: }

   7: @*# Generated: @DateTime.Now.ToString()*@

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s