cdesk458
asked on
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 http://httpd.apache.org/docs/current/mod/mod_cache.html and http://httpd.apache.org/docs/current/mod/mod_proxy.html, I have this so far:
1. In the httpd-proxy.conf, this is the section pertaining to the proxy:
2. In httpd.conf:
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?
Thanks.
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 http://httpd.apache.org/docs/current/mod/mod_cache.html and http://httpd.apache.org/docs/current/mod/mod_proxy.html, 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
ProxyPass http://www.mywebsite.com/ http://www.mywebsite.com/
ProxyPassReverse http://www.mywebsite.com/ http://www.mywebsite.com/
<Proxy *>
Require all granted
</Proxy>
</IfModule>
</IfModule>
2. In httpd.conf:
LoadModule cache_module modules/mod_cache.so
<IfModule mod_cache.c>
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
CacheRoot C:\xampp\apache\cacheroot
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
</IfModule>
</IfModule>
<IfModule mod_cache.c>
CacheLock on
CacheLockPath /tmp/mod_cache-lock
CacheLockMaxAge 5
</IfModule>
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?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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...
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.
There is no difference page is read from SQL or from disk file.
ASKER
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 mod_expires.so 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?