say i have a logout link and it is redirecting to lo-gout servlet
You can configure filters to intercept request/responses before reaching/coming from the servlet. So, upon clicking "logout" it is expected to go to servlet and you can configure a filter before it goes to the actual servlet.
But this has nothing to do with clearing cache. As Bear pointed out, you need to refer the link he provided.