RobertP Posted February 22, 2012 Share Posted February 22, 2012 just checking to see if this is the correct cache method to use? var serverCache = []; $(document).ready(function(){ $(".tooltip").tooltip({ bodyHandler:function(){ serverName = $(this).html(); if(serverCache[serverName]){ $("#tooltip").html(serverCache[serverName]); } else{ $("#tooltip").html("Loading..."); $.ajax({ url:"index.php?sub=serverInfo&server="+serverName, context:$("#tooltip"), success:function(data){ serverCache[serverName] = data; $("#tooltip").html(serverCache[serverName]); } }); } return ""; }, showURL:false, track:true, delay:0 }); }); Quote Link to comment https://forums.phpfreaks.com/topic/257577-cache-methods/ Share on other sites More sharing options...
Adam Posted February 23, 2012 Share Posted February 23, 2012 Looks fine to me. Depends of course on how many tooltips there are? If it's a reasonable number then I would load them all in the first call, instead of one per call. The bottleneck, as you've identified, is in waiting for the request. If the tooltips are used frequently, then I would even consider just defining them as the page is loaded. There's no sense in using AJAX if it's degrading the performance. Quote Link to comment https://forums.phpfreaks.com/topic/257577-cache-methods/#findComment-1320391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.