APC: get a key's expiration time

It’s always surprising to me, but APC is still the best kept secret. APC offers a bunch of very useful features — foremost a realpath cache and an opcode cache. However, my favorite is neither: it’s being able to cache data in shared memory. How so? Simple: use apc_store() and apc_fetch() to persist data between requests. The other day, I wanted use a key’s expiration date to send the appropriate headers (Expires and Last-Modified) to the client, but it didn’t seem like APC supports this out of the box yet....

November 8, 2010 · 1 min

Installing Varnish on Ubuntu Hardy

This is a quick and dirty rundown on how to install Varnish 2.1.x on Ubuntu Hardy (8.04 LTS). Get sources setup Add the repository to /etc/apt/sources.list: Import the key for the new repository: Installation Update sources list and install varnish: Files of importance: Double-check: Further reading I recommend a mix of the following websites/links: Varnish 2.1 documentation Wiki with lots of tutorials and examples Team Soundcloud’s varnishtop (code on Github) Fin That’s all!...

September 14, 2010 · 1 min

Caching for dummies

Caching is one of the things recommended whenever something is slow — “Your [database, website, server]? Well, duh! You need a cache!”. All things aside, it’s not always easy to cache stuff. I find myself often in situations where I can’t cache at all or where a caching solution is complex as hell to implement. All of the sudden you need to dissect your page and lazy load half of it with Ajax — bah....

April 6, 2010 · 3 min