Forum Moderators: coopster
1. Mix of php and html
If you have a page with a mix of php and html does the php cache still work?
e.g.
#### test.php<?php
$var = 1;
//other code here
?>
<html><body><title>test.....
<p>Lot's of html text here....
<?php
//drop back to php because we have a few if tests
if($user == 'joe') {
process_charts($joe, $date);
display_charts();
} else {
display_unathorized_user_info();
}
?>
<p>report complete....
<p>a bit more html here...
</body></html>
In this example test.php starts off in php mode, performs some actions and then drops out to html for the main page data (this way there is no need to have dozens of
print '<html><body><title>';
print '<p>blah, </p>;
Next the code switches back to php mode for checking stuff and finally drops back to html.
So how does a php caching app handle this? Is caching on chunks of php data or 100% pure php files only?
Does the code above cause a performance hit because of the switching modes?
In fact, even without caching is the above code sensible or should it totally be php code and have those dozens of print '<html.... statements (or echo even :-)
2. Small php statements
Similarily what happens to html pages with very small amounts of php?
e.g.
#### index.html<html><body
<h1>Widget World</h1>
.
.
.
<p>loads of html stuff here
<p>Hey, today is <?php echo date("l");?></p>
<p>loads of html stuff here
</body></html>
In this example the page is 10k in size but the only php within it is this <?php echo date("l");?>
How would a caching app handle that? Would it cache that tiny snippet or ignore it?
3. File names
Are only .php files cached? What if the file above was called test.html but had the <?php declarations in it?
but i don't think you can really do that with your example, though, as you seem to be testing for individual users. if you cache the entire page, then it will deliver the same page to each and every person -- which i presume is no use to you. so it looks like you will just have to cache certain bits (like the header, sidebar, or footer, or whatever - the bits that don't change) and then join them together with the uncachable bit at the end.
you will have to split the page into several scripts to do that though.
What I mean is php accelerating where apps are compiled and thus run quicker. In particular ioncube, eacclerator, and apc cache.
But then apc cache describes itself as a "cache and an optimizer" so which is it? And why bother using it if I have setup apache to cache files from memory and if Linux does a lot of caching too!
I can understand the optimizing / compile bit but how does it do that say, in example 2. above where 99% of a page is html and there is just one snippet of php.
[edited by: Frank_Rizzo at 11:32 pm (utc) on April 4, 2007]