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.

Here is more or less a small hack until there’s a native call: