- Dynamic content - generated by using of Web Sever/Application Server running JSP, Servlets etc. This content is dynamically assembled and severed to the browser hence called as Dynamic.
- Static Content - as the name implies this content does not change with request and is static. All multimedia things like image, audio, css, documents etc. come under this category.
In order to do so, we have to setup a Proxy Pass in the main Apache Server(dynamic). This can done at the Apache Server Level by adding the Proxy directive in the httpd.conf file of the server(normally located under /etc/httpd/conf) or in the .htaccess file (located in your web root public_html). Any changes done in httpd.conf needs your server to be restarted for your changes take effect. However if you add in .htacess, these changes are applied immediately, so pickup either of the option what ever works for you. Scenario - Proxy all content in given directory Let's say all your static content was stored in the images folder of your root directory as http://www.yourwebsite.com/images . Now we want this to be served by another Apache Server rather than the main one. So first copy all your files and folder from images directory into the new server. Let's say the new Apache Server is located at this address http://images.yourwebsite.com, then add the following directive in your config file in the VirtualHost Section. ProxyPass /images http://images.yourwebsite.com ProxyPassReverse /images http://images.yourwebsite.com The above example shows the new Address is an subdomain, but it could be another separate server like all together, so you can specify the IP instead as well. ProxyPass /images http://92.293.229.24 ProxyPassReverse /images http://92.293.229.24 It could be local sever e.g Light Httpd serving static files at port 81 locally in the case this directive would be. ProxyPass /images http://localhost:81 ProxyPassReverse /images http://localhost:81
Scenario - Proxy content based on file extension Lets say all your static content was stored in various folder and not just one. So in this case the above approach would not work. So in this case we would identify all the static files by extension and serve them from the static server. Then add this in your config file in the VirtualHost Section. RewriteEngine On RewriteRule "^/(.*).(jpg|jpeg|gif|png|swf|pdf|avi|mpeg|mpg|mp3)$" "http://www.yourwebsite.com/$1.$2" [P] ProxyPassReverse / http://www.yourwebsite.com/ This directive will redirect all .jpg .jpeg .gif .png ... file extensions to your server which hosts static files. As in first Before you use the proxy directive, make sure the directive to load the Proxy modules and RewriteRule is in the config file. LoadModule proxy_module modules/mod_proxy.so LoadModule rewrite_module modules/mod_rewrite.so