Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to start using multiple front-end Apache servers for my website.

At the moment I store various HTML files in a caching directory, e.g. "/htmlcache/homepage.html"

Obviously I don't want to re-cache these files on a per-server basis, I'd rather have one central store. How is this usually done?

The options as I see it are:

  • Database (MySQL) - extra load - should I be storing larrge .html files?
  • Memcache - should this be used for large .html files?
  • Some kind of accessible shared disk - no idea how this would work

Latency is key for me. The disk read opperation is working very nicely for me at the moment.

As an additional complication, I'll also need to keep my PHP session data in a central location too.

This thread: recommends using session_set_save_handler to store the session data in a shared database.

How are you overcoming this issue?

share|improve this question
Perhaps Varnish would suit your needs – Michael Mior Jul 7 '11 at 15:15

memcached can store "large" HTML files (for suitably small values of large) - Varnish (as Michael Mior mentioned) or Squid are other options. Out of those three I would lean toward Varnish (Squid is overkill for most small environments, and I believe Varnish scales better through medium/large environments: Last time I checked Squid wasn't capable of distributed cacheing).
You will need to test any of these solutions before you deploy them, obviously.

Re: the PHP session part - session_mysql is one solution here. Writing your own custom session handler in PHP is another. I would suggest one of the PECL extensions personally as they tend to be marginally more efficient/faster than PHP code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.