Forum Moderators: coopster

Message Too Old, No Replies

Caching PHP files

         

asantos

6:47 pm on Oct 28, 2006 (gmt 0)

10+ Year Member



Can someone recommend me one good php caching class? im running on php4

mcibor

5:19 pm on Oct 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what exactly do you mean, but I usually use ADOdb [adodb.sourceforge.net] with smarty [smarty.php.net]

Hope this helps
Michal

asantos

7:35 pm on Oct 29, 2006 (gmt 0)

10+ Year Member



i mean, is there a way to COMPLETELY cache the php page into some file, so the php engine wont have to recompile the file in "n" minutes.

Frank_Rizzo

9:16 pm on Oct 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you mean something like eaccelerator, zend, phpaccelerator?

jenjen8

9:02 am on Oct 30, 2006 (gmt 0)

10+ Year Member



Here is a list of accelerators. Some are free.
[php.net...]

If you want some simple caching that works, I recommend smarty.
[smarty.php.net...]

asantos

4:03 pm on Oct 31, 2006 (gmt 0)

10+ Year Member



actually i cant use Smarty, i already wrote my own template system.

the thing is, for example, if i get digged, the server will go down because of the requests. i need to cache the already compiled code so that every new request uses the cache instead of recompiling the php again.

What should i use for that?

asantos

4:04 pm on Oct 31, 2006 (gmt 0)

10+ Year Member



btw, i cant use these
[php.net...]

because i dont have access to my servers php.ini or whatsoever. i need a pure-php caching system.

jamie

4:15 pm on Oct 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi asantos,

try Pear's Cache_Lite class. it's simple to use and you can cache portions of the page or the entire html

cheers

FalseDawn

9:15 pm on Oct 31, 2006 (gmt 0)

10+ Year Member




i mean, is there a way to COMPLETELY cache the php page into some file, so the php engine wont have to recompile the file in "n" minutes.

PHP is interpreted, not compiled.
What exactly is your PHP page outputting? Does the output change with every access?
I don't think you are going to find anything to do what you want in PHP itself - the common opcode caches hook into the PHP engine itself to enable them to store (and optionally optimize) the PHP opcode files in on disk and/or in memory.

[edited by: FalseDawn at 9:15 pm (utc) on Oct. 31, 2006]

Psychopsia

12:15 am on Nov 1, 2006 (gmt 0)

10+ Year Member



I read somewhere that interpreted code is faster than compiled code, is that true or not?

FourDegreez

12:48 am on Nov 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Compiled code is faster.

mcavic

4:38 am on Nov 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP is interpreted, not compiled.

Are you sure about that? I thought that PHP and Perl were compiled on-the-fly, but that the compilation happens so fast that it's not usually noticable.

if i get digged, the server will go down because of the requests

I don't think compilation is the problem. It sounds like either the server is inadequate, or the PHP code is doing more work that it should to be doing (loops, inefficient MySQL queries, etc). Any number of connections that Apache can handle should be able to be handled by PHP as well.

mcibor

3:09 pm on Nov 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP is being parsed - this means, it's compiled on the fly and cached.
C++ is compiled = requires compilation before running on any machine
js is interpreted = the interpreter is a browser (lynx doesn't interpret it and ommits js completely)

But it doesn't matter if it is parsed or interpreted or compiled. The slowness could be because of:

1. unoptimized database - check how slow are your queries: microtime after - microtime before.
2. Check for loops, file reading, recurency in your script.
3. Optimize your queries to limit them to 1-3 per page.

Regards
Michal

FalseDawn

4:13 pm on Nov 1, 2006 (gmt 0)

10+ Year Member



PHP is not compiled in the strict sense of the definition - compilation generally produces a stand-alone machine code file that the operating system can execute natively.

PHP scripts are "compiled" into "bytecodes" that the binary file php.exe then interprets and executes(with the help of the other php modules where needed, of course).

So I guess it is "compiled" (in a loose sense of the term), and then "interpreted" :)