By enabling compression on your web server, you’ll speed up the load times of pages on your site by compressing, both ASCII and binary files on the server side, as requested. This will leave the user to decompress them on the other side. Options to enable this are available for both Apache and IIS (Windows), and are supported on all modern web browsers. If a user doesn’t support compression, the server will simply revert to responding with uncompressed content.
The current standard choice is: mod_deflate (compatible alternative available for IIS).
Straightforward gzip compression is less popular, with deflate now being the preferred option: mod_gzip (compatible alternative available for IIS).
- Minification − This is the practice of stripping out white space, comments and other unnecessary data from scripts in order to reduce the over-all size of the code. While it won’t make the code run any faster, this has the advantage of enabling the data to be downloaded more quickly. Minification also works really well when used with the compression techniques mentioned above. We’d recommend Yahoo!’s YUI Compressor to handle the minification of your code. http://developer.yahoo.com/yui/compressor/
OpCode caching (or code acceleration)
Compilation is the process of turning code written by people into a language that the computer understands. Typically, this only needs to happen once. During run-time, high-level programming languages, such as PHP, operate in the same way that other languages behave in compilation.
Scripts written in languages like PHP are compiled ‘on-the-fly’ by an interpreter, which translates them into lower-level code that the computer understands. This happens every single time the PHP script is executed. At this point, I’m sure you can see why this can be wasteful in a server environment!
Fortunately, there are various tools and frameworks available to help reduce the waste. They help by caching the compiled code, so that it’s not re-compiled when it’s not needed. These tools include (but are not limited to):
- eAccelerator − for PHP, available from http://eaccelerator.net/
- APC (Alternative PHP Cache) − available at http://pecl.php.net/package/APC
- XCache − for PHP, available from http://xcache.lighttpd.net/.
The truth is that there’s always more you can be doing, but we hope you’ve found something in these blogs to help you along the way. Do feel free to give one of the team at Melbourne a shout if you have any questions.