Camen Design Forum

PHP and filesystem efficiency?

Dan Zollman

First off, I don't know the answer to your question.

Second, I have a similar caching mechanism, but with selective removal. It works well because of the way my blog system is structured; I don't know whether it would be a good idea to generalize this for other sites, but maybe it's worth sharing.

There are three parts to the process:

1. In the cache directory, there is a folder for each URI minus the GET parameters. For example, there is folder for article.php. Inside that folder, there is a cache for every combination of GET params: article.php?foo=1, article.php?foo=2, etc.

2. When a given page is changed, the page's cache folder can be deleted. When a comment is posted on article.php, then the article.php cache folder is deleted. Even if there were multiple versions from different GET params, that takes care of all of them.

3. Each function that affects page content has a set of instructions or a pattern that describes what cache items need to be removed. When a new article is posted or updated, the cache for every article listing page is cleared.

I only delete the entire cache when I'm pushing an update to the site itself.

Append

(Leave this as-is, it’s a trap!)

Only the original author or a moderator can append to this post.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn