xml and xslt
A repository of notes and comments that will eventually make their way into the documentation. Please treat the information here with caution, it has often not been verified.
What are the best things to tune for better performance?
The main configuration item is the dependency-check-interval especially for Windows. For deployment, you should set it something high like 60s or larger.
You can also change the cache-mapping values, especially for stuff like *.gif files that don't change. Higher values mean that the browsers won't need to go back to the server.
Other than that, most of the default configuration values are pretty good, so you normally won't need to touch them.
The most important performance tweak you can make is to set Expires or better Last-Modified and/or ETag values on your servlet/JSP output. If the servlet/JSP output only changes every 15 minutes, as for a news page, then caching it can be a big performance win.
Of course, for stuff like shopping carts and stuff that's personalized, that won't help. But for many sites, the most heavily hit pages can be cached.
Is Apache faster than Resin Standalone?
For small files, Resin is about 10-20% faster. For large files (1M), they're essentially identical. (It's possible that the very latest Apache has improved performance.)
For JSP and Servlets, Resin standalone is certainly faster than Resin/Apache. Because of the extra overhead of the Resin/Apache connection, the Resin/Apache configuration is necessarily slower than Resin standalone.
It's only static files where Apache could be faster. Well, there's an exception for SSL. It's conceivable that Apache/Resin with SSL would be faster that Resin with SSL.
What is the performance loss with a Servlet or JSP comparted to a static file?
With Resin standalone, JSP files are essentially as fast as static files (as long as you don't actually do any processing. :-)
If Resin is behind another web server, like IIS or Apache, there is a performance decrease with JSP and Servlet files, which comes from the overhead needed for the communication between the other web server and Resin.
What gets cached when a servlet does a forward?
The only thing that matters is the HTTP headers. So if you telnet to the server, you should be able to see whether the headers are properly set or not.
In the case of a forward, you should be able to just set the headers without needing to modify the JSP itself.
One thing to be aware of: the caching is based on the original URL. So if your forwarding servlet varies it's output based on some request headers (like User-Agent), it needs to set the Vary header.
<cache-mapping> is a related but somewhat separate issue, and I think we haven't explained it properly.
<cache-mapping> only works on cacheable responses which have not set the Expires header. If you're missing the Expires header, <cache-mapping> will set it for you.
So your servlet still needs to do some work. <cache-mapping> isn't all that you need. The reason that <cache-mapping> works with normal files is that Resin's FileServlet sets the Last-Modified and ETag headers, but does not set the Expires header.
What if while the cache is being filled, another request comes?
Resin 'fills a cache' the first time a request comes in. If another request comes in and Resin has not finished filling the cache, the second request will be treated as uncachable. This means that until the cache is filled, requests will miss the cache and get serviced directly.
This is also what happens when the cache expires. The first request to come in after the expiry time invalidates it, and while it is being filled the other requests pass through to the resource being cached.
This behaviour may be changed in Resin 3.0, updates are available here.