Monday, March 1, 2010

Apache for Static, Tomcat for Dynamic

Following on from my previous post what I wanted to do next was allow for the apache web server to handle all the static content on my web app and Tomcat to only handle the dynamic content. Again I found Linux Journal to be a fantastic resource. The article - "Separate the Static from the Dynamic with Tomcat and Apache" gave me basically what I needed to do this plus much more. This article can be found here.

Essentially all that was required was to tell apache where to find the static content in the virtual host definition in the httpd.conf file. To do this all that was required was set up an alias for static content as follows:
Alias /staticContent/ /var/www/staticContent/


In my JSP now when I put the apache server serves up the static content rather than Tomcat. This means that image1.jpg or any static content such as javascript can be changed and redeployed without restarting any server.

No comments: