Miles Elam wrote:

> I want to put a Slashdot feed on my web page with the following (out 
> of context for brevity):
>
> <pipeline>
>  <map:match pattern="feeds/slashdot.org">
>    <map:generate src="http://slashdot.org/slashdot.xml"/>
>    <map:serialize type="xml"/>
>  </map:match>
> </pipeline>
>
> This works fine, but the server opens a socket to Slashdot on every 
> request to my page.  If my site gets some traffic, Slashdot will not 
> be happy with me.  Further, my bandwidth usage goes up.  And when 
> Slashdot (and others) become slow, my site will become slow right 
> along with them.  None is particularly appealing.
>
> From the Slashdot syndication page (slashcode): "Do whatever you want, 
> but *don't* access the file more than once every 30 minutes."
>
> I went hunting in the mail archives for user and dev and came up with 
> the following:
>
> <pipeline expires="now plus 30 minutes">
>  <map:match pattern="feeds/slashdot.org">
>    <map:generate src="http://slashdot.org/slashdot.xml"/>
>    <map:serialize type="xml"/>
>  </map:match>
> </pipeline>
>
> No difference.  My server's still hitting Slashdot over and over.  I 
> tried telnet-ing to the port to at least check for "expires" headers. 
> No dice.  I looked at HttpHeaderAction but that doesn't seem to touch 
> Cocoon's cache at all (so of limited use to me).  I've used both 2.0.3 
> and 2.1 CVS (as of two weeks ago).
>
> A part of me smiles when I think that if Slashdot ever "slashdotted" 
> me, they would be somewhat slashdotted themselves, but this is not my 
> intent and I very much want to be a decent feed client.
>
> Anyone have any ideas?  ...preferably with little stress on my server.


If you have not found solution yet... Extend FileGenerator and override 
generateKey() and generateValidity() methods.
generateKey() may return something like HashUtil.hash(this.source), and 
generateValidity() can return new DeltaTimeCacheValidity(30) to cache 
response for 30 minutes.

See cacheable.xsp for sample code.

Vadim



> - Miles Elam




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to