Caching PHP scripts.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anguz
    Member
    • Mar 2004
    • 47

    #1

    Caching PHP scripts.

    I was wondering, what would be the best way to cache PHP scripts that I use here at Dathorn? I specify the hosting part because I'm sure the tool may depend on what's already there to be used with PHP.

    I'd like a way to have the script already interpreted by PHP so it runs faster, although I'm not sure I'm saying this right.

    Thanks in advance for any help you can give me!
  • Buddha
    Senior Member
    • Mar 2004
    • 825

    #2
    Zend Encoder would help performance some. Should work with the Zend Optimizer that's already on the server.

    As for real caching, I think Zend has moved all that in to the Zend Platform which cost 1000 buck per cpu or something.

    There are other free options like APC which you could probably use on one of those new VPS accounts Andrew is working on.
    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

    Comment

    • sdjl
      Senior Member
      • Mar 2004
      • 502

      #3
      You could write yourself a script which takes the output of your code and then dumps it down to a text file for later inclusion.
      This is how i do my caching:

      1) Call cache_include('this_function', $param1); function with function that you want to cache and it's parameters.
      2) cache_include(); creates a filename based on the parameters you give it. For the above call, it would be this_function_param1value.php
      3) cache_include(); looks for the above filename to see if we already have cached code with an include call:
      PHP Code:
      if(@include($filename)) {
      // File exists
      } else {
      // File doesnt exist

      4) If the file exists then we don't use anymore code, the include we did shows the output that was cached previsouly.
      If the file doesn't exist, then we call the function that we want to get output for and save down it's output into a file.

      It's quite a simple way of caching a function and i'm sure there are more efficient ways of doing so, but it works well for me and has done for the past year or so

      You can also add a time globabl variable, so that if the cached output is older than a certain date, then it recaches itself.

      David
      -----
      Do you fear the obsolescence of the metanarrative apparatus of legitimation?

      Comment

      • anguz
        Member
        • Mar 2004
        • 47

        #4
        sdjl, I'm looking for a way to cache the script in compiled state, rather than the output of the script.

        Buddha, how could I use Zend to cache the script in compiled state? I was looking at Turck MMCache, actually.

        VPS are on their way to dathorn?! Great! Where can I read more on this?

        Comment

        • anguz
          Member
          • Mar 2004
          • 47

          #5
          Note: I just found the MM Cache development is now continued as eAccelerator.

          Edit: Found the topic on VPS http://forums.dathorn.com/showthread...&highlight=vps
          Last edited by anguz; 02-19-2005, 04:24 PM.

          Comment

          • Buddha
            Senior Member
            • Mar 2004
            • 825

            #6
            Originally posted by anguz
            Buddha, how could I use Zend to cache the script in compiled state? I was looking at Turck MMCache, actually.
            Zend Accelerator (not the Zend Optimizer which is better known and free) has been integrated into what is called the Zend Platform. Zend Platform, mmCache and APC all do bytecode caching which is what you seem to be interested in.

            The Zend Encoder, which I mentioned, basically compiles your script to bytecode and saves it to a new file, sort of caching it. However it's not as good as bytecode caching because the script is still read from the disk each time. Bytecode caching that uses RAM will even improve a poorly design script because your cutting out a big bottleneck the disk drive.

            There's also the PHP Accelerator from IonCube too. Not to be confused with the IonCube Encoder which is similar to the Zend Encoder.

            mmCache would be a good choice because it's mature in it's development and hopefully stable. mmCache is suppose to be faster than Zend Accelerator too which would explain Zend's decision to integrate the Zend Accelerator into the Zend Platform.

            Zend Platform is just too expensive for me to even consider and does a lot more than just bytecode caching too. Nothing like blowing the hell out of KISS (Keep It Super Simple) in the name of marteting.
            "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

            Comment

            Working...