Don’t call me DOM

10 March 2006

Doing HTTP caching in PHP

Filed under:

Since the Mobile Web Best Practices highlights that caching is a particularly important feature when browing the Web on a mobile device, I just wrote a new associated technique on how to do proper caching when using PHP.

While Mark Nottingham’s excellent tutorial on the topic covers most of it already, the technique provides some additional code example, as well as some illustration as how to use it with MySQL.

Nothing ground breaking, but I’ve been using this code in most of my PHP applications over the past years, and it certainly gives a nice and warm feeling of being a good HTTP citizen when you pass the Cacheability validation.

(As we’re trying our best to keep the Mobile Web Initiative home page in conformance with the best practices, this code has just found a new usage in a mobile context…)

One Response to “Doing HTTP caching in PHP”

  1. Alexandre Says:

    This is a nice initiative.
    It is indeed quite rare that PHP scripts take advantage of the full potential of HTTP/1.1.

    A while ago, I have written an Open Source library dedicated to this purpose, handling all types of HTTP/1.1 conditional requests, HEAD requests, caching, compression, and a RSS/ATOM special mode:

    http://alexandre.alapetite.net/doc-alex/php-http-304/

Picture of Dominique Hazael-MassieuxDominique Hazaël-Massieux (dom@w3.org) is part of the World Wide Web Consortium (W3C) Staff; his interests cover a number of Web technologies, as well as the usage of open source software in a distributed work environment.