How does one disable Caching in jQuery Mobile UI How does one disable Caching in jQuery Mobile UI jquery jquery

How does one disable Caching in jQuery Mobile UI


Thank you for the answers guys, and even though they didn't quite work for me they did point me in the direction to find the code I was looking for.

This is the code that I found on this gentleman's Github Gist.

https://gist.github.com/921920

jQuery('div').live('pagehide', function(event, ui){  var page = jQuery(event.target);  if(page.attr('data-cache') == 'never'){    page.remove();  };});

There is also a back button code in that Gist, but I don't seem to need it really as my back button seems to work just fine...


Page caching is now off by default in jQM RC1. See the extract below from the jQM website about page caching: http://jquerymobile.com/demos/1.0rc1/docs/pages/page-cache.html

If you prefer, you can tell jQuery Mobile to keep previously-visited pages in the DOM instead of removing them. This lets you cache pages so that they're available instantly if the user returns to them.

To keep all previously-visited pages in the DOM, set the domCache option on the page plugin to true, like this:

$.mobile.page.prototype.options.domCache = true;

Alternatively, to cache just a particular page, you can add the data-dom-cache="true" attribute to the page's container:

<div data-role="page" id="cacheMe" data-dom-cache="true">

You can also cache a page programmatically like this:

pageContainerElement.page({ domCache: true });

The drawback of DOM caching is that the DOM can get very large, resulting in slowdowns and memory issues on some devices. If you enable DOM caching, take care to manage the DOM yourself and test thoroughly on a range of devices.


Have you tried to overwrite the default value ?

$(document).bind("mobileinit", function(){    $.mobile.page.prototype.options.domCache = false;});

This works for me