You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robby Pelssers <ro...@ciber.com> on 2009/08/07 12:45:13 UTC

adding expires headers with cocoon

Hi guys,

 

I'm building a new cocoon app (cocoon2.2) and performance really comes
into play so after reading
http://developer.yahoo.com/performance/rules.html  I'm trying to get an
A-grade for all rules ;-) 

 

Now I'm focusing on "Add an expires or cache-control header" so I
started googling around.  I was reading this thread
http://www.mail-archive.com/cocoon-dev@xml.apache.org/msg16951.html
about adding support for settings expires headers.  But reading the
official cocoon documentation I did not found anything back.  Does
cocoon have built-in support to do so and are there
examples/documentation of how to accomplish this?

 

And by the way... anyone who has experience with configuring ETags??

 

Thx in advance,

 

Robby Pelssers


Re: adding expires headers with cocoon

Posted by Lars Huttar <la...@sil.org>.
On 8/7/2009 5:45 AM, Robby Pelssers wrote:
> Hi guys,
> 
>  
> 
> I’m building a new cocoon app (cocoon2.2) and performance really comes
> into play so after reading
> http://developer.yahoo.com/performance/rules.html  I’m trying to get an
> A-grade for all rules ;-)
> 
>  
> 
> Now I’m focusing on “Add an expires or cache-control header” so I
> started googling around.  I was reading this thread
> http://www.mail-archive.com/cocoon-dev@xml.apache.org/msg16951.html
> about adding support for settings expires headers.  But reading the
> official cocoon documentation I did not found anything back.  Does
> cocoon have built-in support to do so and are there
> examples/documentation of how to accomplish this?
> 
>  
> 
> And by the way… anyone who has experience with configuring ETags??
> 
>  
> 
> Thx in advance,
> 
>  
> 
> Robby Pelssers
> 

I thought I'd forward to the list this reply from my colleague to
Robby's question:

Robby,

Our web applications run on the 2.1 strain of Cocoon, so things might be
implemented slightly differently in 2.2.  But, it looks to me like they
are the same.

To add an Expires header, I use the action HTTPCacheAction:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/HttpCacheAction.html

There is also a 2.2 version of the page:
http://cocoon.apache.org/2.2/core-modules/core/2.2/1049_1_1.html

>>From the above webpage, the HTTPCacheAction is:
"This action adds the Last-Modified, Expires and Cache-Control HTTP
headers to the response.

This action will add the Last-Modified header to the response with the
time in which the request was executed, and an Expires header at a
specified time difference. Additionally, it will provide an extra
Cache-Control indicating the maximum age of the request as a delta
between the expiration and last modification dates."

In my Cocoon sitemap, I have declared multiple HTTPCacheAction actions,
each for a different length of time--i.e a no-cache, short-cache,
medium-cache, and long-cache.

Here is an example of declaring the long-cache action in the Cocoon sitemap:
<map:actions>
	<map:action name="long-cache"
src="org.apache.cocoon.acting.HttpCacheAction">
		<days>30</days>
		<hours>0</hours>
		<minutes>0</minutes>
		<seconds>0</seconds>
	</map:action>
</map:actions>

Once the actions are defined (and after a Cocoon restart), all I have to
do to use these them is to add the <map:act type="{name of
map:action}"/> element to the pipeline match that I want to have an
Expires header.

To use the long-cache map:action declared above, I add the <map:act
type="long-cache"/> element to a pipeline match:
<map:pipeline>
	<map:match pattern="**.js">
		<map:act type="long-cache" />
		<map:read mime-type="text/javascript" src="javascript/{1}.js"
type="resource"/>
	</map:match>
</map:pipeline>

Hope this helps,
Rick Harman
Web Application Development
SIL International

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org