Troubles adding html5 application caching to a Cappuccino application

30 views
Skip to first unread message

KC

unread,
Feb 8, 2012, 2:19:56 PM2/8/12
to Cappuccino & Objective-J
I am trying to add html5 application caching to my cappuccino
application.

I have had partial success, but cannot consistently catch an
application cache update ready event. I want to catch this event so I
can force a reload of my application on new releases.
Sometimes I can change the manifest comments and it behaves as I
expect and sometimes the update ready event never fires. (I am
careful to clear my cache before each attempt).
I suspect a timing issue or some conflict with how event listeners are
handled by cappuccino. Is what I am doing somehow incorrect for
cappuccino? Help!


Here is what I did:

I made the following changes to my Jakefile which causes the
generation of the app.manifest and adds the manifest tag to the
resulting index file.
-----------------------------Jakefile
changes--------------------------------------------------------------------------
var THEMANIFEST = require("objective-j/cache-manifest");
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
THEMANIFEST.generateManifest(FILE.join($BUILD_DIR, "Release/
MyApp"));
});
-------------------------------------------------------------------------------------------------------------------------------

I added the following script to my index.html before any other
scripts.
-----------------------------index.html
changes---------------------------------------------------------------------
<script type="text/javascript">
//
// Check if a new cache is available on page load.
// but only if html5 appcache supported in the first place
if (window.applicationCache)
{
window.addEventListener('load',
function(e)
{

window.applicationCache.addEventListener('updateready',
function(e)
{
if (window.applicationCache.status ==
window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
window.applicationCache.swapCache();
alert('Update to MyApp detected -
reloading application now');
window.location.reload();
}
},
false);
},
false);
}
</script>
-------------------------------------------------------------------------------------------------------------------------------

I have changed my appache server to handle the text/cache-manifest
MIME type.

KC

unread,
Feb 22, 2012, 8:13:19 PM2/22/12
to Cappuccino & Objective-J

FYI:

The html5 application caching problem turned out to be a Firefox 3.6
issue.
(https://bugzilla.mozilla.org/show_bug.cgi?id=683794).

My code worked fine on Firefox 10.

Kerri
Reply all
Reply to author
Forward
0 new messages