How to tell Apache reverse proxy to return cached pages

There are multiple people accessing my website, but either the traffic is too much now, or my server has gotten too slow.
I am trying to improve performance and return cached pages to the users, instead of them accessing the server directly all the time.
I way I thought of to do it is with a reverse proxy, which will return cached pages.
Following the documentation and, I have this so far:
1. In the httpd-proxy.conf, this is the section pertaining to the proxy:
<IfModule proxy_module>
<IfModule proxy_http_module>

# Reverse Proxy
ProxyRequests Off


<Proxy *>
      Require all granted


Open in new window

2. In httpd.conf:
LoadModule cache_module modules/
<IfModule mod_cache.c>
    LoadModule cache_disk_module modules/
    <IfModule mod_cache_disk.c>
        CacheRoot C:\xampp\apache\cacheroot
        CacheEnable disk  /
        CacheDirLevels 5
        CacheDirLength 3

<IfModule mod_cache.c>
    CacheLock on
    CacheLockPath /tmp/mod_cache-lock
    CacheLockMaxAge 5

Open in new window

In the specified cacheroot folder, there are numerous data and header files (which means that caching is working).
However my website is still being ridiculously slow.
My server is a Win 2008 R2, running Apache 2.4 and MySQL inside XAMPP.

Anything I'm missing?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
what you should be doing is informing the users browser to retrieve  pages / static information.from its cache.

ExpiresActive On
ExpiresDefault "access plus 300 seconds"

<Directory "/home/website/public_html">
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    ExpiresByType text/html "access plus 1 day"
    ExpiresByType text/css "access plus 1 day"
    ExpiresByType text/javascript "access plus 1 day"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 day"

Open in new window

you might want to use a free caching service i.e.

please note there is no one size fits all solution here..  On the server side you want to keep frequently used files open or in memory (a file open takes a significant amount of time but the system has a finite limit of the # of file handles available.  Set your cache folder to use an SSD if available.  Caching increases the memory load of the application

MySQL may be starved for memory or attempting to use too much memory .. if possible have the sql data on a different spindle (physical drive) than the website. if possible have 3 hard drives .. Operating system and programs, Website Data, SQL data, if you want to use server side caching then add yet another hard drive for its cache.  What we're trying to do here is reduce the # of disk seeks and disk thrashing.  What you need to do is use a performance analyser to accurately diagnose where the problem may be and work on one problem at a time.

Given a specific set of hardware there is a limit of how many requests per second can be handled per server you may have gone over this limit and then only by adding load balancing (another web server) (or many web servers) and possibly many clustered mysql databases accessing clustered data drives.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cdesk458Author Commented:
Thanks for the input David.
The web server would need more disks and RAM, that's for sure.

In the meantime I implemented you suggested rules, but getting the same behavior.
What I did:
1. included the module which ExpiresActive and ExpiresDefault require.
2. included your directives for xampp/htdocs directory.
3. I let the server run for a while to ensure caching for happening into cacheroot.
4. I shut down mysql, and attempted to access my website again, hoping to see a cached page, but got a mysql error instead. Is this a valid test case? Are my expectation correct in this scenario?
David Johnson, CD, MVPOwnerCommented:
I shut down mysql, and attempted to access my website again, hoping to see a cached page, but got a mysql error instead. Is this a valid test case? Are my expectation correct in this scenario? as expected as you have static content and dynamic content. you can't cache dynamic content normally and also the cache needs to check to see if the data has changed therefor it will always look at the source and only then can it determine if the source and the cache are in sync of if the source is newer
Need More Insight Into What’s Killing Your Network

Flow data analysis from SolarWinds NetFlow Traffic Analyzer (NTA), along with Network Performance Monitor (NPM), can give you deeper visibility into your network’s traffic.

Set KeepAlive ON and compress text/*, that will relieve the wires a lot (in addition to what others said)
PageSpeed and Yslow are better teachers than people...
cdesk458Author Commented:
I still would like to somehow keep the website displayed even if mysql goes down, as I work on a migration plan...

With KeepAlive On in httpd, the behavior is the same - the website is not accessed (trying to hit the web server, doesn't use cache).

Even with all services running, if the web server is getting slow, I would like the proxy to return its cache instead of hitting the server. I mean, is there a performance threshold when mod_proxy chooses to return a cached page instead of hitting the server?

I'm looking now at the Yslow analyzers, it's very useful. There are some suggestions to use compression for text. I don't know how that's done yet, need to explore...
You need cache in RAM (not mem cache, but disk cache in ramdisk due to apache bugs)
There is no difference page is read from SQL or from disk file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.