HomePHP Building Object-oriented Web Pages with HTTP Compression in PHP
Building Object-oriented Web Pages with HTTP Compression in PHP
Here we go! Welcome to the third -– and last -- part of the series “Using HTTP compression in PHP.” Just in case you didn’t know, this set of tutorials explores the advantages of using HTTP compression on dynamic PHP pages, reducing their download times and increasing the overall performance of PHP applications.
Stepping back for a moment to the second part of the series, I’m sure you’ll recall that I explained how to introduce “Gzip” encoding as part of a generic data compressing PHP class. I coded this by using the PHP built-in “gzencode()” function, in order to compress dynamic output generated by parsed PHP files.
As you saw, this simple (and powerful) approach allowed me to use HTTP compression, only spawning a single “DataCompressor” object and eventually using its corresponding methods. Although this object-based approach is pretty basic in its conception, it’s actually very useful for demonstrating how HTTP compression can be used when writing either procedural or object-oriented PHP code.
Now, bringing our attention to the subject of this last tutorial, I’ll extend the application of “Gzip” encoding on dynamic PHP pages by implementing the data compression method that I explained before, within a PHP application that uses objects as the driving force for creating dynamic web pages. In short, what you’ll learn is how to compress parsed PHP pages, which, as I said before, are generated on the fly by a bunch of web page objects.
Having drawn the guidelines for this article, it’s a good time to start learning how to use HTTP compression on object-oriented web documents. Let’s go!