I have a traffic hungry site that I'm planning to redesign. I would like to take advantage of PHP to split pages into header, footer and sidebar. The overall content will NEVER change. I'm only preferring PHP to ease layout in future. I would definitely install APC and MemCached and was wondering how the performance and memory consumption of the cached PHP would compare against a .HTML page?
I am using CSS! Infact CSS3! The thing is my header.php is much more than styling. I often like to change the look of the site and that might not be possible with just CSS. Anyways, that doesn't answer my question!
HTML never has to go server side, so it will always be faster than PHP. But, if you have memcache, your php can remain in memory and execute very quickly. You will not see a noticeable difference between HTML and minimal PHP. Plus if the page never changes, like MySQL queries are all the same, php code is same, you can just cache everything. It will run substantially faster.
Thanks danej. Out if all the stupid replies above, you atleast read the question. The thing is you wrote exactly what I has in my mind. The question somehow still remains! Is Cached PHP slower than HTML?
Yes definitely faster. Depending on your server's RAM/CPU, the number of requests it would be able to handle will increase/decrease, but the ratio between serving HTML and PHP pages is considerably different in terms of milliseconds, the more connections per second that are established, the slower the response will get - as it grows, the drop rate will also increase if running in PHP mode. With static HTML pages, there is no overhead in the backend to do anything, its just serving a file as opposed to having initialize the PHP compiler and having it process the PHP page. Apache will serve the pages right away without having to request the actual response from PHP engine.
you cant just move to memcached that instantly. you need to do this one step at a time. first you must separate your website to different layers, i assume that you know that architectural layers for an application. you must go first to SOA then easily go for memcached. logic behind memcached is very similar in storing cache data to client/users local pc. but memcache is deployed on a dedicated server. so on the client side, we first access the memcache server and checks if data stored doesnt have any changes. if it does it will now request the application server.
and yes if you use memcache, it will be faster. imaging your data is cached on the visitor/user cache memory. it lessens or eliminates requests to your server.