0

In one of my Jquery plugin application, I have one window which opens a JSP page displays rows from database.

In Internet Explorer, except when I run application after I start for first time, all the time this page doesn't display all the rows from database till I Clear Cache in Fiddler plugin. After doing this, all rows are displayed properly and after some this problem happens again.

In this JSP page I have the following but it doesn't help.

 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
 <META HTTP-EQUIV="Expires" CONTENT="-1">

There is a call to servlet, however doGet method is not called from JSP.

How can I resolve this issue? This problem happens only in Internet Explorer

Jacob
  • 14,463
  • 65
  • 207
  • 320

1 Answers1

1

You can try instead of doing it in HTML markup, do it in JSP:

 response.setHeader("Cache-Control", "no-cache");

Try other methods like:

 response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");

And if this is just a problem for you as a user, make sure to set IE to pull a new version of the page "Every Visit to the Page" rather than the default setting of "Automatic" which doesn't work very well. (In IE8, Tools->Internet Options->Browsing history section, Settings button.)

Also when calling a page via Ajax or opening a window with Javascript you can add an extra parameter to the URL that is just a timestamp or random number to trick IE into dealing with the request as a new one.

developerwjk
  • 8,619
  • 2
  • 17
  • 33
  • Thanks for pointing this out. I have tried as mentioned in this post http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers/2068407#2068407. I have used HML option and since it has not cached, I am still testing. By the way which takes precedence, HTML or JSP? And what you have mentioned about adding extra parameter to URL, do you have an example for this? – Jacob Oct 31 '13 at 19:03
  • 1
    When you set the caching via JSP like above its sent as part of the HTTP headers which are read before the HTML is parsed and I think the headers take precedence over the HTML meta tags. Adding the extra parameter, I just mean like if your url is go.jsp?id=1 then make it go.jsp?id=1&trick=12345678 where 12345678 is a timestamp or random number which you can generate in Javascript – developerwjk Nov 01 '13 at 18:42
  • developerwjk I will try this approach. Thanks – Jacob Nov 01 '13 at 18:44
  • Another question is randon number generation must be using javascript? Can I generate random number using Java and pass in parameter string? – Jacob Nov 01 '13 at 19:15
  • If you're opening pages with Javascript or doing AJAX calls it makes sense to do it in Javascript. Of course for links in the site you can append something like this on the link in JSP if you want. – developerwjk Nov 01 '13 at 20:03