info.magnolia.module.cache.filter
Class ResponseExpirationCalculator

java.lang.Object
  extended by info.magnolia.module.cache.filter.ResponseExpirationCalculator

public class ResponseExpirationCalculator
extends Object

Calculates how long a shared cache may hold a response based on its response headers. The most restrictive policy gets used while respecting the precedence rules dictated by RFC-2616. More specifically:

Given Cache-Control: max-age=5 and Cache-Control: max-age=15 the most restrictive is 5.

Given Cache-Control: max-age=5 and Cache-Control: s-maxage=15 the latter has precedence resulting in 15.

If either of Pragma: no-cache, Cache-Control: no-cache and Cache-Control: private is present the response is considered to be already-expired. Uses Apache HttpClient to parse the headers.

Version:
$Id$

Constructor Summary
ResponseExpirationCalculator()
           
 
Method Summary
 boolean addHeader(String name, Object value)
           
 int getMaxAgeInSeconds()
          Returns the number of seconds the response can be cached where 0 means that the its already expired and must not be cached and -1 means that there's no information on how long it can be cached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseExpirationCalculator

public ResponseExpirationCalculator()
Method Detail

addHeader

public boolean addHeader(String name,
                         Object value)

getMaxAgeInSeconds

public int getMaxAgeInSeconds()
Returns the number of seconds the response can be cached where 0 means that the its already expired and must not be cached and -1 means that there's no information on how long it can be cached.



Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.