org.loom.servlet
Class CacheControl

java.lang.Object
  extended by org.loom.servlet.CacheControl

public class CacheControl
extends java.lang.Object

Contains the caching information related to the response object. This information tells the browser about how it is expected to cache the server response.


Constructor Summary
CacheControl()
           
 
Method Summary
 CacheControl forever()
          Sets the response to never expire.
 java.lang.Boolean getCacheNever()
           
 java.lang.Integer getCacheSeconds()
           
 java.lang.String getEtag()
           
 java.util.Date getLastModified()
           
 boolean isResourceModified(LoomServletRequest request)
          Compares this CacheControl data with the request headers, and returns true if the browser page is outdated and a new one should be sent.
 CacheControl never()
          Invoke this method to never cache
 void setCacheDays(int days)
          Deprecated. use withDays(int) instead
 void setCacheForever()
          Deprecated. use forEver() instead
 void setCacheHours(int hours)
          Deprecated. use withHours(int) instead
 void setCacheMinutes(int minutes)
          Deprecated. use withMinutes(int) instead
 void setCacheNever()
          Deprecated. use never() instead
 void setCacheSeconds(java.lang.Integer seconds)
          Deprecated. use withSeconds(Integer) instead
 void setCacheYears(int years)
          Deprecated. use withDays(int) instead
 void setEtag(java.lang.String etag)
          Deprecated. use withEtag() instead
 void setLastModified(java.util.Date lastModified)
          Deprecated. use withLastModified() instead
 CacheControl withDays(int days)
           
 CacheControl withEtag(java.lang.String etag)
           
 CacheControl withHours(int hours)
           
 CacheControl withLastModified(java.util.Date lastModified)
           
 CacheControl withMinutes(int minutes)
           
 CacheControl withSeconds(java.lang.Integer seconds)
           
 CacheControl withYears(int years)
           
 void writeHeaders(LoomServletResponse response)
          Write the headers for a 200 (OK) or 304 (NOT_MODIFIED) response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheControl

public CacheControl()
Method Detail

isResourceModified

public boolean isResourceModified(LoomServletRequest request)
Compares this CacheControl data with the request headers, and returns true if the browser page is outdated and a new one should be sent. If false, a 304 could be sent instead. If both lastModified and etag has been specified, this method will return true if any is missing or incorrect in the browser request.

Parameters:
request - the current servlet request
Returns:
true if a new page should be sent, false to send a 304

writeHeaders

public void writeHeaders(LoomServletResponse response)
Write the headers for a 200 (OK) or 304 (NOT_MODIFIED) response.


setCacheForever

public void setCacheForever()
Deprecated. use forEver() instead

Sets the response to never expire. Invoking this method will set the cache to expire ten years in the future, instead of the HTTP spec recommendation of one year.


forever

public CacheControl forever()
Sets the response to never expire. Invoking this method will set the cache to expire ten years in the future, instead of the HTTP spec recommendation of one year.


getLastModified

public java.util.Date getLastModified()

setLastModified

public void setLastModified(java.util.Date lastModified)
Deprecated. use withLastModified() instead


withLastModified

public CacheControl withLastModified(java.util.Date lastModified)

getEtag

public java.lang.String getEtag()

setEtag

public void setEtag(java.lang.String etag)
Deprecated. use withEtag() instead


withEtag

public CacheControl withEtag(java.lang.String etag)

getCacheSeconds

public java.lang.Integer getCacheSeconds()

setCacheSeconds

public void setCacheSeconds(java.lang.Integer seconds)
Deprecated. use withSeconds(Integer) instead


withSeconds

public CacheControl withSeconds(java.lang.Integer seconds)
Parameters:
seconds - the number of seconds to store the resource in the browser cache, starting now

setCacheMinutes

public void setCacheMinutes(int minutes)
Deprecated. use withMinutes(int) instead


withMinutes

public CacheControl withMinutes(int minutes)
Parameters:
minutes - the number of minutes to store the resource in the browser cache, starting now

setCacheHours

public void setCacheHours(int hours)
Deprecated. use withHours(int) instead


withHours

public CacheControl withHours(int hours)
Parameters:
hours - the number of hours to store the resource in the browser cache, starting now

setCacheDays

public void setCacheDays(int days)
Deprecated. use withDays(int) instead


withDays

public CacheControl withDays(int days)
Parameters:
days - the number of days to store the resource in the browser cache, starting now

setCacheYears

public void setCacheYears(int years)
Deprecated. use withDays(int) instead


withYears

public CacheControl withYears(int years)
Parameters:
years - the number of years to store the resource in the browser cache, starting now

getCacheNever

public java.lang.Boolean getCacheNever()

setCacheNever

public void setCacheNever()
Deprecated. use never() instead


never

public CacheControl never()
Invoke this method to never cache