When users logout from my mobile app, how can I make sure the cache is cleared?
What I'm thinking about is to redirect /logout to a specific page that clears the cache and redirects to the front page, but how do I clear everything from the cache?
I'm using jQuery Mobile 1.0b2pre.
Here's how I solved it:
My /logout
action where the users session is destroyed in the backend redirects to /exit
which has an id attribute of exitPage
.
In my JavaScript I have asked jQuery Mobile to trigger when that page is about to be created. I then empty the DOM and redirects to the front page.
/exit:
<div data-role="page" id="exitPage"></div>
/my.js:
jQuery('#exitPage').live('pagebeforecreate', function(){
jQuery(document).empty();
window.location.replace('/');
});
you can't clear the cache. but what you can do is identify the user based on his session id, and append that to the assets urls someimage.png?cachecontrol=blablalba
next time it enters, he will have a new session id so he will get new files even if the old ones are still in the cache. the other solution will be to explicitly set the cache control header to no-cache. but you can't force his browser to clear it's cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With