Re: [Opensymphony-oscache] Cache works but doesn't recognize changes in underlying data

Rachael Russell <[email protected]> Tue, 30 Aug 2005 13:49:47 +0100
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <[email protected]>
--------------080102070308060505000301
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

John wrote:

>Ok, I answered my own question. 
>Everything started working as I wanted when I put the following at the top of the page (tile)
><%
>response.setHeader("Expires", "0");
>// Date in the past
>response.setHeader("Cache-Control" ,"no-cache, must-revalidate");
>// HTTP/1.1
>response.setHeader("Pragma", "no-cache");
>// HTTP/1.0
>%>
>The reason is that the entire page was getting cached by Tomcat. OSCACHE is meant to cache portions of the JSP page so what that means is you want the page to render every time EXCEPT for the cached portion or more specifically, the content within the <cache:cache..> tags. When I added the code above to stop the overall page from being cached by tomcat the portion of code that built the key and executed the cache tag was executed EVERY TIME as I wanted. However, the oscache content remains cached. If the data changes, it is recognized through the key. So it's working correctly.
>So, in the end, I think that tomcat was interferring with checking the cache.
>- John
>
>---------------------------------------------------------------------
>Posted via Jive Forums
>http://forums.opensymphony.com/thread.jspa?threadID=6206&messageID=14063#14063
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [email protected]
>For additional commands, e-mail: [email protected]
>
>  
>
Erm AFAIK The header responses cause the client (ie the browser) to not 
cache the page. Tomcat only caches the compiled JSP code - still has to 
generate the HTML whenever the page is hit.... that's the biggest 
advantage of OSCache that i've found - so tomcat doesnt have to generate 
the HTML, instead it just grabs the OSCache version of the html, 
lowering stress on tomcat.

So you're just telling the client browser to not cache the page, thereby 
causing the client to hit your server every time that page is requested, 
rather than when the page has changed.

I dont think there are tags avaialble to update the cache if the data 
changes - that may be something that is handled programatically rather 
than in the tag library?? Correct me if i'm wrong (as this would be 
really good! Rather than reloading the cache to see if data has changed, 
thereby reducing the number of cache reloads on data that doesnt update 
very often/non-periodic updates).


???
cheers
Rach

-- 
5 Prospero House
48-50 Minories
LONDON EC3N 1JJ
07931 926 113
[email protected]


--------------080102070308060505000301
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
John wrote:
<blockquote
 cite="mid30474084.1125340214558.JavaMail.os-j2ee@opensymphony01.contegix.com"
 type="cite">
  <pre wrap="">Ok, I answered my own question. 
Everything started working as I wanted when I put the following at the top of the page (tile)
&lt;%
response.setHeader("Expires", "0");
// Date in the past
response.setHeader("Cache-Control" ,"no-cache, must-revalidate");
// HTTP/1.1
response.setHeader("Pragma", "no-cache");
// HTTP/1.0
%&gt;
The reason is that the entire page was getting cached by Tomcat. OSCACHE is meant to cache portions of the JSP page so what that means is you want the page to render every time EXCEPT for the cached portion or more specifically, the content within the &lt;cache:cache..&gt; tags. When I added the code above to stop the overall page from being cached by tomcat the portion of code that built the key and executed the cache tag was executed EVERY TIME as I wanted. However, the oscache content remains cached. If the data changes, it is recognized through the key. So it's working correctly.
So, in the end, I think that tomcat was interferring with checking the cache.
- John

---------------------------------------------------------------------
Posted via Jive Forums
<a class="moz-txt-link-freetext" href="http://forums.opensymphony.com/thread.jspa?threadID=6206&messageID=14063#14063">http://forums.opensymphony.com/thread.jspa?threadID=6206&amp;messageID=14063#14063</a>


---------------------------------------------------------------------
To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
For additional commands, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>

  </pre>
</blockquote>
<font size="-1"><font face="Tahoma"><big>Erm AFAIK The header responses
cause the client (ie the browser) to not cache the page. Tomcat only
caches the compiled JSP code - still has to generate the HTML whenever
the page is hit.... that's the biggest advantage of OSCache that i've
found - so tomcat doesnt have to generate the HTML, instead it just
grabs the OSCache version of the html, lowering stress on tomcat.<br>
<br>
So you're just telling the client browser to not cache the page,
thereby causing the client to hit your server every time that page is
requested, rather than when the page has changed.<br>
<br>
I dont think there are tags avaialble to update the cache if the data
changes - that may be something that is handled programatically rather
than in the tag library?? Correct me if i'm wrong (as this would be
really good! Rather than reloading the cache to see if data has
changed, thereby reducing the number of cache reloads on data that
doesnt update very often/non-periodic updates).<br>
</big><br>
<br>
</font></font>???<br>
cheers<br>
Rach<br>
<pre class="moz-signature" cols="72">-- 
5 Prospero House
48-50 Minories
LONDON EC3N 1JJ
07931 926 113
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a></pre>
</body>
</html>

--------------080102070308060505000301--