KC
unread,Feb 8, 2012, 2:19:56 PM2/8/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.