4

I have a HTML website running off Apache and using a MySQL database. I want to speed up my Apache server's response time. I want to get advice on which way I should go? I read on Google that Varnish is used with Apache. So I have two questions:

  1. Can I use Memcache with Apache or not?
  2. If Yes then which one is better, Memcache or Varnish?
Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
user115079
  • 711
  • 1
  • 11
  • 23
  • possible duplicate of [Memcache(d) vs. Varnish for speeding up 3 tier web architecture](http://stackoverflow.com/questions/4490140/memcached-vs-varnish-for-speeding-up-3-tier-web-architecture) – Bo Persson Jun 20 '12 at 17:49

1 Answers1

14

Comparing Varnish and Memcached is like comparing apples and oranges. Varnish is a caching reverse HTTP proxy, and it sits in front of your Apache web server. Memcached on the other hand is a distributed object caching system. It can be used, for instance, to cache content retrieved from the MySQL server.

Not knowing anything about the specifics of your website, I would say Varnish is the simplest way to go. You could, in theory, just throw it in front of your Apache and have your pages fly. Of course this is not the case in real life. You need to tune Varnish to your specific needs to handle cookies, cache banning etc. efficiently.

Memcached requires changes to your code. You need to go through your code, investigate where you could gain leverage from caching and implement changes as required.

Neither Varnish nor Memcached provides a plug-in solution to speed up your site, but both are excellent tools to help you reach that goal.

Ketola
  • 2,767
  • 18
  • 21
  • I would add that varnish also will require changes to your website in many cases. Varnish will not set cookies and it would not be appropriate to cache any dynamic pages (such as a cart, account page, contact form, etc.). If you had a simple blog and used AJAX or some external service to do comments it might be ideal. Ideally you also need to be able to selectively flush the varnish cache when you DO change a page on your website. – runamok Dec 14 '12 at 02:39