The following tutorials taught me how to make PHP pages cacheable. If you do not manually set your PHP page’s HTTP headers, that page is generally uncacheable by browsers, reverse proxies, HTTP accelerators, etc. That might make sense for highly dynamic pages or personal/sensitive information, but there are plenty of situations where PHP generated content can and should be cached.
- Ned Martin’s Site Guide — Caching
- PHP, HTTP/1.1 dates and Conditional Get
- Implementing support for Conditional Get with PHP
- Cache-Friendly PHP Applications (I think this is copied from a book without permission
) - PHP Cache Control script
- Cache Control with PHP
There is a typo in Ned Martin’s guide: “Last-Modified” is hyphenated! (Took me forever to figure out why I couldn’t set that header.)
Use the Cacheability Engine and the Live HTTP Headers extension for Firefox to debug as you go. Remember that shift-clicking reload/refresh forces the browser to fetch a fresh copy of the page.
Apologies for the short and sporadic posting. I’m busy hacking Zenphoto for another project.
P.S. Another plug for my host NearlyFreeSpeech.NET; Squid HTTP acceleration on shared hosting for mere pennies rocks! The availability of Squid made me look into HTTP caching for PHP pages.
If you liked this post, please subscribe to my feed. Thanks for visiting!


A great list of cacheable tutorials. I use caching in my code and it speeds up PHP by at least 500 times. Why PHP doesn’t have innate caching I don’t… in fact, I do, because otherwise sales for their Zend Accelerator would be non-existant.
Thanks, Adam. Indeed, caching rocks.
I think you’re referring to PHP opcode caching rather than HTTP caching described here? There might be other non-monetary reasons that PHP doesn’t cache opcode out of the box. Many shared hosts do not run any of the mature and free opcode cachers out there because memory can be a bigger bottle-neck for them than CPU load I hear. Opcode caching sacrifices memory to save CPU cycles. One of PHP’s biggest strength is that it “just works” in almost any environment, and opcode caching would change that.
Can’t wait till I get a VPS so I can run my own opcode cache.