Reputation: 6740
Hi guys im a bit confuse with Apc and template caching.
By i mean template caching is something like smarty caching functionality.
Basically what is the difference between both of them
Upvotes: 0
Views: 764
Reputation: 62894
ajreal's answer is a good one. I'll just add the following:
Smarty's template caching, and APC's opcode caching, are the same thing at different levels. If you've got a smarty template, and no caching going on anywhere, here's (roughly) what needs to happen in order to execute the template:
1) Run (lex, parse, and intepret) the smarty template code. The end result is PHP code.
2) Run that PHP code. The output here is php bytecode.
3) Run the Bytecode. The output here is machine code. (unless there's some intermediate step I don't know about).
4) Run the machine code.
Caching in smarty caches the output from step 1.
APC caches the output from step 2.
Upvotes: 0
Reputation: 47321
APC cache is to compile php script into executable binary op-code and used it later.
In short, compile once, stored into memory, and reusable until time-to-live ended, or until file get updated.
Despite this major usage, APC also can used to store run-time variables into memory (you can treat this as global session for everyone accessing the same page)
While smarty caching technically is not a binary op-code cache, PHP binary still need to convert it to binary op-code every time it get executed.
What benefits of smarty caching as is it will stored the rendered HTML/output into disk (or you can save the output into APC, the second usage)
Which mean, it save the execution cycle instead of compilation cycle
Upvotes: 1