I have a problem with caching in my new servlet. Currenly I am using Eclipse and Tomcat for development. I noticed that when I request a page the page is compiled and instantiated. The page would get data from the database and display it. I would then goto a new page to update the data expecting the prior page to display it differently. When returning to the original page (without using the back button) the value displayed is the previous one even though it was changed. I believe this is something to do with caching. I used the praga/no-cache and Cache-control/no-cache headers without avail. Is this something relating to the fact that the servlet eclipse generates does not contain a getLastModified function? If this is the case how would I go about fixing it? Thank you in advance I used IE5.5 for testing
I have not tried that. Wouldn't the user get a Page Expired message if they chose the back button? Not that this is not desireable. Is this the normal procedure for situations like this? I would have expected that a user requesting a page (servlet) would not be cached but reran. [ March 15, 2004: Message edited by: Scot Meyer ]
I just tried adding <% response.setHeader("Cache-Control", "no-cache"); %> <% response.setHeader("Cache-Control", "must-revalidate"); %> <% response.setHeader("Pragma","no-cache"); %> <% response.setDateHeader("Last-Modified",System.currentTimeMillis());%> to my page response and this still didn't fix it. It's as though the servlet is not being called and the information is being cached in the web server. Is it possible that Apache is causing this?
Ok did some additional testing. The JSP is definately not being called when the page is requested a second time. It will be called if I hit the Refresh button. So I am guessing this is an Apache setting. Currently my httpd.conf file states that the file_cache_module, headers_module, and cern_meta_modules are not loaded. Thank again for any help I meant Tomcat 5.0 not Apache. [ March 16, 2004: Message edited by: Scot Meyer ]
Ok, I loaded all the source for tomcat and steped through the page. It appears as though if on a page reload(refresh) the code is called. I put a breakpoint at the earliest point in the tomcat source of the Http11 connector. This is a step after the thread is created. Whats intereting is if I hit the enter key or retype the url in the address bar the page is not requested again even if I set the caching headers (in the above post). So it must be that IE doesn't resumit a request if it thinks the page is exactly the same (When it obviously isn't) Im sure I am overlooking something obvious.