• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and caching...  RSS feed

 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some scripts that generate a drop down box by selecting items from a db. The user has the option to create a new item- If this is done a pop-up box comes up and they're able to save the new item to the db from there.
Of course when they close the pop-up the new item won't appear in the drop down box, but it should if I refresh the page, right? It's not... It doesn't appear unless I close the browser and load the page from scratch.
I'm guessing that JSP is caching the list of options for me... or something. Is there something I can do to fix this?
Any ideas, suggestions or comments are appreciated. Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's much more likely that it's the browser doing the caching. Did you add the necessary headers to the page to cause it to expire immediately?
Bear
 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll check on the browser thing... but I'm not sure what you're referring to by the headers that make the page expire immediately. Could you enlighten me?
Thanks-
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We use:
<%
response.addHeader( "Expires", "0" );
%>
on all pages we wish to expire.
hth,
bear
 
HaHa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following three lines of codes may ensure that the page is not cached in all browsers:
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
Hope it helps,
Haha
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!