<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.14.1">
</HEAD>
<BODY>
On Mon, 2007-07-30 at 12:43 +0800, K J wrote:
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">Using an engine such as Smarty (<A HREF="http://smarty.php.net/">smarty.php.net</A>) gives you more granular control of caching page elements, but I'm not exactly sure what you want to cache.</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE>
<FONT COLOR="#000000">I'm looking to cache things like, "recently logged in members", or "latest blog posts". Would it be best to use Smarty for this? Or Memcache? With Memcache, all web servers will be able to obtain the same data, whereas with Smarty, each web server would have to cache its own. </FONT><BR>
</BLOCKQUOTE>
</BLOCKQUOTE>
Smarty provides you with a mechanism to cache HTML templates, the default method being to file. This guy has a memcached backend for Smarty: <A HREF="http://swag.dk/swag/kode/">http://swag.dk/swag/kode/</A><BR>
<BR>
If you're gonna cache data in memcache and handle the page build and rendering yourself, you don't need Smarty.<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">Often SQL query caching isn't hugely beneficial as your database server most likely caches pretty well. Caching HTML portions to reduce database queries will most likely give you a huge performance benefit.</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE>
<FONT COLOR="#000000">I'm not understanding you here. Do you mean, it can speed things up a lot if I cache the end result HTML portion in Memcache?</FONT><BR>
</BLOCKQUOTE>
</BLOCKQUOTE>
You can cache HTML fragments in memcache, or you can cache the data that you need to build those fragments in memcache. What works best depends on your setup. YMMV!<BR>
<BR>
Rob.<BR>
<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000"> </FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">On 7/30/07, </FONT><FONT COLOR="#000000"><B>Rob Sharp</B></FONT><FONT COLOR="#000000"> <<A HREF="mailto:rob.sharp@thesoundalliance.net">rob.sharp@thesoundalliance.net</A>> wrote:</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE>
<FONT COLOR="#000000">On Mon, 2007-07-30 at 11:44 +0800, K J wrote:</FONT><BR>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">There are portions of my PHP application that updates every 5 minutes or so. Thus I think it's a great candidate for caching, as opposed to having the server refresh that portion every time there's a query.</FONT><BR>
</BLOCKQUOTE>
<FONT COLOR="#000000">Yes, there's huge benefits to be gained from it.</FONT><BR>
<BLOCKQUOTE TYPE=CITE>
<BR>
<FONT COLOR="#000000">As far as I'm aware, there isn't a PHP partial page caching available is there? </FONT><BR>
</BLOCKQUOTE>
<FONT COLOR="#000000">Using an engine such as Smarty (<A HREF="http://smarty.php.net/">smarty.php.net</A>) gives you more granular control of caching page elements, but I'm not exactly sure what you want to cache.</FONT><BR>
<BLOCKQUOTE TYPE=CITE>
<BR>
<FONT COLOR="#000000">So, I'm thinking of using Memcache instead. Now, I can cache the SQL queries, or I can cach that portion of the page (with html rendered). However, if caching that portion, it would mean more internal LAN traffic for every page view request.</FONT><BR>
</BLOCKQUOTE>
<FONT COLOR="#000000">Often SQL query caching isn't hugely beneficial as your database server most likely caches pretty well. Caching HTML portions to reduce database queries will most likely give you a huge performance benefit. </FONT><BR>
<BR>
<FONT COLOR="#000000">Do you currently have issues with LAN traffic that make you think using memcache will be a problem? You need to move a lot of data around to saturate a gigbit switch.</FONT><BR>
<BR>
<FONT COLOR="#000000">You may also consider a sole memcache instance per web server, whereby traffic would not leave the server, which may help if you have network saturation issues. </FONT><BR>
<BR>
<FONT COLOR="#000000">Thanks,</FONT><BR>
<FONT COLOR="#000000">Rob.</FONT><BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<TABLE CELLSPACING="3" CELLPADDING="0" WIDTH="100%">
<TR>
<TD COLSPAN="2" VALIGN="top">
<B><FONT SIZE="2"><FONT COLOR="#333333">Rob Sharp</FONT></FONT></B><BR>
<FONT SIZE="1"><FONT COLOR="#ce4a84">Development Lead </FONT></FONT><BR>
<BR>
<B><FONT SIZE="1">telephone:</FONT></B><FONT SIZE="1"> 02 9282 4049</FONT><BR>
<B><FONT SIZE="1">facsimile:</FONT></B><FONT SIZE="1"> 02 9282 4099</FONT><BR>
<B><FONT SIZE="1">skype:</FONT></B><FONT SIZE="1"> qu4nnum</FONT><BR>
<BR>
<BR>
<BR>
<BR>
</TD>
</TR>
<TR>
<TD COLSPAN="2" VALIGN="top">
<FONT SIZE="2"><FONT COLOR="#333333">Sound Alliance </FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#ce4a84">inthemix : FasterLouder : Thought By Them : SameSame</FONT></FONT>
</TD>
</TR>
</TABLE>
<BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#339966">100% recycled electrons were used for the composition of this email </FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#339966">- please don't print it unless you need to!</FONT></FONT>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
</BLOCKQUOTE>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<TABLE CELLSPACING="3" CELLPADDING="0" WIDTH="100%">
<TR>
<TD COLSPAN="2" VALIGN="top">
<B><FONT SIZE="2"><FONT COLOR="#333333">Rob Sharp</FONT></FONT></B><BR>
<FONT SIZE="1"><FONT COLOR="#ce4a84">Development Lead </FONT></FONT><BR>
<BR>
<B><FONT SIZE="1">telephone:</FONT></B><FONT SIZE="1"> 02 9282 4049</FONT><BR>
<B><FONT SIZE="1">facsimile:</FONT></B><FONT SIZE="1"> 02 9282 4099</FONT><BR>
<B><FONT SIZE="1">skype:</FONT></B><FONT SIZE="1"> qu4nnum</FONT><BR>
<BR>
<BR>
<BR>
</TD>
</TR>
<TR>
<TD COLSPAN="2" VALIGN="top">
<FONT SIZE="2"><FONT COLOR="#333333">Sound Alliance </FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#ce4a84">inthemix : FasterLouder : Thought By Them : SameSame</FONT></FONT>
</TD>
</TR>
</TABLE>
<BR>
<FONT SIZE="1">"Poor workers blame their tools. Good workers build better tools. The best workers get their tools to do the work for them." -- Syndicate Wars</FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#339966">100% recycled electrons were used for the composition of this email </FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#339966">- please don't print it unless you need to!</FONT></FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>