This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes I've got some nice Cache Filter for ye! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "I Watch "I New topic

I've got some nice Cache Filter for ye!

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Hey guys!

I was reading some material about filters and stuff, and I came upon a cache filter, that would store data in temporary files, and I didn't like it very much (I found it to be inefficiant, and code was a female dog to maintain).

What I was thinking is that as far as I know, Tomcat doesn't cache anything (which is its major disadvantage and the reason people use it with apache, which I also hate - 2x bugs). Also, I was thinking, that my browser has cache enabled, and so do most other browsers. So, why in the first place have server handle cahing, when the client can do it?

So, I wrote this little filter, which seems to work perfectly, already saving my server Gigs of bandwidths.

Let me know what you think, and if people seem to like it, maybe it's a good idea to ask Tomcat administration to ship this server with Tomcat?

Basically, here's the filter itself:

Here's the mapping that you should have in your web.xml:

And here is the /WEB-INF/

So, what you think?
[ June 29, 2004: Message edited by: Ivan Jouikov ]
I agree. Here's the link:
subject: I've got some nice Cache Filter for ye!
Similar Threads
Browsing with the back button
File upload
Log redirection
HTTP Status 404 - /Struts2Application1/clientAction + Please help
Sitemesh with Websphere6.1