NEW FEATURES: Built-in compression and caching, very high performance PHP

From: Date: Sat, 28 Oct 2000 20:02:01 +0000
Subject: NEW FEATURES: Built-in compression and caching, very high performance PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22478@lists.php.net to get a copy of this message
Hello, The Web developed is reaching an higher level of maturity. Technologies have been developed to make better use of resources that usually are limited and/or expensive. The use of compression and smart caching tecnologies is not a new thing but when used with wisdom thay can take products like PHP to the next level in the ability to handle high volume sites. - Compression Compressing HTML is not a new thing and there are already Web server modules for Apache, IIS, etc.. to do so on-fly. The results are astonishing because it turns HTML pages that are basically text into a compressed chunk which in average is becomes 5 times smaller using the gzip encoding. - Caching Compression is great but it takes CPU time. So it takes database queries, XML transformations and other operations that are frequently used to compose dynamically generated Web pages. For Web sites that have dynamically generated content that is not critical to be updated frequently, a common technique is to take the load to a background process that periodically pregenerates the HTML pages and stores them on disk cache. If necessary, pages are refreshed in periods of a few minutes. For high volume Web sites this is a big improvement because it offloads the server greatly saving a lot of money that otherwise would be spent in large load balanced server farms. Some servers come with interesting modules for this purpose. For instance Apache comes with mmap, that caches content (HTML pages, images and other static content) in the server shared memory, thus avoiding disk access. mod_mmap http://modules.apache.org/search?id=43 Spider (dumb) Cache http://modules.apache.org/search?id=252 - PHP PHP can go father. PHP can combine compression and caching in itself, therefore without depending on somebody else server modules. Furthermore, most caching technologies are dumb because they try to guess what's worthy to be cached looking at the HTTP query strings or response headers. PHP based caching can be controlled from within the scripts that generate the pages, so it's up to the programmer to decide when pages should be cached and how. A programmer could insert PHP commands in the scripts right before outputting any data or headers saying for instance: cache all requests to this URI for about 5 minutes. Then for subsequent requests to that URI PHP would take the page contents from the cache until the cache expires. For very critical pages, there could be an option to tell PHP to cache pages in shared memory (if available) rather than in disk, like mod_mmap does. Furthermore, if the user agent (user browser or proxy server) supports compression, PHP would take care of serving gzip compressed version of the page or not if it is not suitable. There are a lot other interesting possibilities about PHP controlled automatic compression and caching of dynamically served Web content, but this should already give a lot for you to think about. I have been planning to implement some day, but recently I was hire for a new job that takes most of my free time. Still I have a lot of knowledge and insight in this field that I am willing to share with whoever is interested to move on and start working on the next step of an High Performance PHP. Just keep replying to this thread. Regards, Manuel Lemos Interesting links: http://www.cis.ohio-state.edu/htbin/rfc/rfc2068.html http://www.mozilla.org/projects/apache/gzip/ http://www.microsoft.com/TechNet/iis/httpcomp.asp Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp --

« previous php.general (#22478) next »