var cache = []; $.get('/update.php', function(mode){ if (cache[mode]) { $('.conten').html(cache[mode]); } else { $.get(response + '.php', function(response){ cache[mode] = response; $('.conten').html(cache[mode]); }); });