How does one disable Caching in jQuery Mobile UI

Serhiy picture Serhiy · Jan 11, 2011 · Viewed 59.9k times · Source

Tried...

<div data-role="page" data-cache="30"> 
<div data-role="page" data-cache="never">
<div data-role="page" data-cache="false"> 
<div data-role="page" cache="false">

Nothing seemes to work... so at the moment I'm fixing the problem on the server-side via...

.'?x='.rand()
.'&x='.rand()

I don't want to disable the AJAX just the caching. There has to be a better way though... am I missing something?

Thanks,

Serhiy

Answer

Serhiy picture Serhiy · Jun 30, 2011

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...