Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I put a caching server in front of my web site?

I have a web site using apache httpd as the server and mysql as the backend. It publishes a "thought for the day" that has gotten so popular that the server is crashing due to the number of requests. Since the same page is been requested (the thought only changes once a day), is it possible to put a caching server in front of my main server, so that when the same request is made by different clients, the caching server returns the page without having to go to the database?

like image 839
Eamon Avatar asked Dec 01 '22 08:12

Eamon


2 Answers

For slow changing pages, a cache will definitely reduce CPU usage; but in your extreme case, where the page changes once a day, and it's perfectly predictable, it would be far easier to use a simple and fast static file server (lighthttp, nginx, etc) and a cron job to change your "thought of the day" every night.

In fact, a lot of non-interactive web pages can be done this way: periodically rebuild html files from database or any other source, and use simple, fast static web servers.

like image 58
Javier Avatar answered Dec 04 '22 03:12

Javier


Absolutely. There are many products that will work well for this. Apache itself can be configured to function this way although, if you are on Linux or UNIX, Squid is the better option as it is specifically designed to do this very job.

On Windows, MS has always offered cache/proxy products that will do this function. Currently this is ISA Server 2006. Although this is dramatically overkill for this type of application.

Squid is my recommendation.

like image 31
Scott Alan Miller Avatar answered Dec 04 '22 02:12

Scott Alan Miller