RSS Feed
15
Oct.
2003

Thoughts about caching with Struts Actions, Tiles and JSP

Talking to the database on each request is not necessary because the content of my weblog does not change very often (for now =) ). So I like the idea of using a cache. Whenever I add a new entry I could send a notification to the cache and the cache would be flushed. So far so good. The tricky thing now is that I am using Tiles and putting a cache taglib into the tile would have no effect because the correspondig Action, which talks to the database, would still get called. Therefore I need a cache logic before the Action gets called. Currently I think the best solution would be to write a special filter. The filter would cache a defined URL, e.g. http://woeye.highteq.net/weblog/show.do?author=woeye and flush the cache on special events. Perhaps I should take a look at OSCache from OpenSymphony?

Any ideas or suggestions?

Comments

1. Yann
http://actioncache.neteye.org works pretty good for me

2. rsk
You could maintain a system-wide variable (servlet context value?) "invalidatedCache" or something to that extent. When a post is performed, part of the post processing could be to set that value to "true" in the ActionForm. So the next time someone requests a page: ClassContainingContent content = // ... if(invalidatedCache) // pull new data into 'content' //do something with content Doesn't require any fancy caching system. Granted if you need sexier features, then the fancy caching systems come in handy :)