Jump to content

Recommended Posts

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
});
});

Link to comment
https://forums.phpfreaks.com/topic/257577-cache-methods/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/257577-cache-methods/#findComment-1320391
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.