PHP
  Home arrow PHP arrow Caching Result Sets in PHP: Cost-efficient PHP acceleration
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Caching Result Sets in PHP: Cost-efficient PHP acceleration
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 21
    2005-10-03


    Table of Contents:
  • Caching Result Sets in PHP: Cost-efficient PHP acceleration
  • The first caching approximation: serializing and unserializing data
  • A fully functional result set caching system: modifying the original script
  • Putting the pieces together: implementing the result set caching script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Caching Result Sets in PHP: Cost-efficient PHP acceleration
    ( Page 1 of 4 )

    With many websites using a database backend for storing and delivering content, certain common problems arise. One of these is a situation that causes the server to slow down or even bring the system to a complete halt. What can you do to reduce the load on your server? This tutorial discusses one method, a result set caching system, and demonstrates how to implement it with either a procedural or an object-oriented approach.

    Introduction

    On the Web of today, most websites heavily use a database backend for storing and delivering content. This directly implies establishing many connections to the database server, performing queries and retrieving result sets for displaying data. Particularly, when one site is attracting many visitors, this process rapidly introduces an overhead on the server that may lead to slower performance or, in critical situations, to complete system halts.

    Addressing the problem from a developer's point of view, there are many methods one can use to reduce the server overload. The first basic method to improve the performance of a website may be done naturally, by reducing the amount of data sent to the client. This benefit can be easily obtained using byte-shaving techniques, such as binary file optimization (images, Flash files and so forth), (X)HTML, CSS, and JavaScript optimization, and finally HTTP compression, since most modern browsers support data compression in a transparent way. Fortunately, PHP offers a set of useful functions to handle efficiently compressed data.

    The second method consists of sending data to the client as infrequently as possible. This concept immediately bring us to a couple of widely known improvement mechanisms: server and client caching. While client-based caching is mostly based on the inherent browser's ability to cache different files, relying strongly on a well-defined caching strategy, server-side caching offers a wider range of possibilities.

    As you probably know, one nice way to implement server-side caching is by caching the entire HTML output generated by a PHP script (known as HTML output caching). This technique is used by popular PHP packages such as Smarty and PEAR:Cache_Lite. It allows you to work with more complex caching methods, including chunked caching, that is, several sections of a page that are individually cached according to a given data "freshness" policy.

    However, HTML output caching is not very flexible. When the entire output is cached in a file, post processing on data may become a serious difficulty, since the whole script output, including the data and the HTML markup, is stored conjunctly in the same physical place.

    On the other side, there is another caching method, useful for reducing the overhead in resource-consuming processes: result set caching. Certainly, caching result sets in a separate location can introduce major benefits, since it reduces the need to execute queries each time the page is accessed, while maintaining enough flexibility to carry out further processing on the data.

    The main objective of this article series is to demonstrate how to implement a result set caching system, either taking a procedural approach or an object-oriented solution, in this way reducing the overall server overload when working with high traffic database-driven websites.

    Are you feeling motivated to find out more about the topic? All right, let's get started!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT