Site Network: Personal | Professional | Photography

Technical Blog

This blog will contain content related to Java, Seam, Security, my sites and projects, as well as other technical subjects I am interested in.

Comments and questions are welcome!

ATG Cache Header Control Module

Saturday, February 2nd, 2008

Many ATG application server static content, or semi-static content, from within the ATG application's .war file. It is often much simpler to package CSS, JavaScript, Flash, Images, and other files in your web application than to try to manage them separately and deploy correctly in development and production instances.

It is often desirable to set long cache times for static content and you may also want to ensure that certain other files or URIs are never cached. Unfortunately ATG does not provide a mechanism for tuning the cache headers.

I have created a new ATG Module which allows you to easily adjust cache header times based on mime-types and URIs, including parent directories. You can download it here: DSCacheControl ATG Cache Header Control Module.

I have built and tested it using ATG 7.1 I will be releasing one for ATG 2007.1 in a bit, which may be based on a Servlet Filter instead, but I haven't decided yet. This one may work on ATG 2007.1, I haven't been able to test it yet.

It is very simple, with two classes: a pipeline servlet and a custom comparator, and two config files: the pipeline servlet's configuration and an Initial.properties to start the servlet. The source code is included in the module.

It allows you to control the cache time used to build the cache related response headers based on the requested asset's mime-type and URI location. It has an order of precedence of a default setting of 0 seconds (do not cache at all), then the mime-type settings are used, and then the URICacheMap is examined to find the most specific entry which is the specific URI or a parent directory. This should allow you to setup basic settings, and override them for specific directories or files as needed.

Here are some example config settings to give you an idea:

mimeTypeCacheMap=image/png=604800, \
image/jpeg=604800, \
image/gif=604800, \
application/x-javascript=604800, \
application/x-Shockwave-Flash=604800, \
flv-application/octet-stream=604800, \
text/html=0, \
text/css=604800

URICacheMap=/myapp/images=2592000, \
/myapp/index.jsp=2342343, \
/myapp/other.jsp=1342342, \
/myapp/images/changing-image.jpg=3600, \
/myapp/huge-static-jsp.jsp=2592000

To install it, simply download the zip file, unzip it, copy the module into your ATG 7.1 root directory and add the module to the list of DYNAMO_MODULES in your environment.sh (or add it using the -m option on the command line when you start ATG). You will likely want to override the default configuration. The .properties file is heavily commented and should be simple to understand. You can edit it within the module if you like, although of course the better approach is to set your cache settings in your application module or in localconfig, depending.

If you try it, please give me your feedback. If you enhance it, please share the code back with me.

13 Steps to peace of mind

Sunday, December 16th, 2007

If you're uptight about uptime, if you're anxious about availability, if you nervously watching Nagios, have I got the program for you. Forget 12 step programs, mine has 13!

First let's talk load balancing. Load balancing is basically distributing some type of load across multiple servers or resources. For the sake of simplicity, we'll assume that it's web requests to web servers that we're talking about, but it's all equally applicable to databases, mail servers, or just about any other network accessed computing resource (assuming you can handle the back-end synchronization if required, such as with a database).

There are two primary reasons to load balance:

  1. Capacity: one server may not have enough power or resources to handle all of the requests, so you need to break the load out across multiple servers.
  2. Redundancy: relying on a single server means that if it fails, everything is down. A single point of failure can bring down your critical application. Servers fail; both hardware and software. A blown power supply, bad RAM, a dead NIC, eventually something will go out. No software is 100% bulletproof either. If you have two or more servers handling the load, then even if one fails, the other(s) can take over without your application or users seeing any difficulties.

A load balancer sits between your users (human or machine) and your servers. It typically passes requests through to multiple servers and returns the responses to the end user, acting like a transparent proxy. It can distribute load in many different ways, randomly, round-robin, or in more complex ways. It usually monitors the servers so that if a server dies it is removed from the pool and no user requests are sent there.

Load Balancing Diagram

(more...)

10MinuteMail.com hit digg.com’s front page last night

Sunday, November 26th, 2006

It's filtered down a few pages off the front, but hey, front page of digg.com! Wow! Totally grassroots in about 4 hours. Now it's on all kinds of little blogs and tech forums and other odd places. Over 100k hits in the last 18 hours. It performs very well. There's very little cpu hit at all. Go SEAM!

Anyhow, I'm proud. Check it out and let me know what you think!

Digg.com:
"A disposible email service...You can read them, click on links, and even reply to them. The e-mail address will expire after 10 minutes."

read more | digg story