Paul Stanton-4 wrote
> 
> Hi All,
> 

Hi!


Paul Stanton-4 wrote
> 
> In a t5.1 app, I thought it was worth checking every request path and 
> setting the 'no-cache' response headers for all page/ajax requests.
> 
> I'm not sure if this is still needed, but my required behaviour is that 
> all page and ajax requests are NEVER cached, while all assets are ALWAYS 
> cached.
> 
> Does tapestry now take care of this, or do I still need to set the
> headers?
> 

You have to decorate the PageResponseRenderer (and AjaxResponseRenderer).
Why did you think Tapestry will do this out of the box? I guess this would
be bad practice for most applications (we have to do it because of security
restrictions).

Here's our PageResponseRenderer:

public final class CacheHeaderPageResponseRendererDecorator implements
PageResponseRenderer
{
        private final PageResponseRenderer delegate;

        private final Response response;

        public CacheHeaderPageResponseRendererDecorator(PageResponseRenderer
delegate, Response response)
        {
                this.delegate = delegate;
                this.response = response;
        }

        public void renderPageResponse(Page page) throws IOException
        {
                response.setHeader("Cache-Control", "no-cache");
                response.setHeader("Pragma", "no-cache");
                response.setDateHeader("Expires", 0);

                delegate.renderPageResponse(page);
        }
}


Paul Stanton-4 wrote
> 
> Thanks, Paul.
> 

You're welcome!

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/browser-cache-response-headers-page-ajax-asset-requests-tp5511964p5513984.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to