|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.net.CachedObject
This class represents a cached object.
For more complete information about Caching in HTTP, please refer to the following:
CacheManager,
Serialized Form| Constructor Summary | |
CachedObject(CacheManager cacheManager)
Constructs a CachedObject with the specified
cacheManager. |
|
CachedObject(HttpResponse httpResponse,
CacheManager cacheManager)
Constructs a CachedObject with the specified
httpResponse and cacheManager. |
|
CachedObject(HttpResponse httpResponse,
ice.net.HttpSession httpSession)
Deprecated. As of 1.6.0. |
|
CachedObject(ice.net.HttpSession httpSession)
Deprecated. As of 1.5.0, replaced by . |
|
| Method Summary | |
static long |
calculateCurrentAge(long ageValue,
long dateValue,
long requestTime,
long responseTime)
Calculates the current age of this CachedObject. |
static long |
calculateFreshnessLifetime(long maxAgeValue,
long expiresValue,
long dateValue,
long lastModifiedValue,
long responseTime,
long cacheExpirationBuffer)
Calculates the freshness lifetime of this CachedObject. |
long |
getAge()
Gets the age HTTP header field value in milliseconds of this CachedObject's HttpResponse. |
byte[] |
getdata()
Deprecated. As of 1.6.0, replaced by . |
long |
getDate()
Gets the date HTTP header field value in milliseconds of this CachedObject's HttpResponse. |
long |
getExpires()
Gets the expires HTTP header field value in milliseconds of this CachedObject's HttpResponse. |
String[] |
getHeaderKeys()
Gets all the HTTP header field names of this CachedObject's HttpResponse. |
String[] |
getHeaders()
Gets all the HTTP header field values of this CachedObject's HttpResponse. |
long |
getLastAccessed()
Gets last accessed time in milliseconds of this CachedObject. |
long |
getLastModified()
Gets the last modified HTTP header field value in milliseconds of this CachedObject's HttpResponse. |
long |
getMaxAge()
Gets the max-age cache directive of the Cache-Control HTTP header field value of this CachedObject's
HttpResponse. |
long |
getRecivedAt()
Deprecated. As of 1.6.0, replaced by . |
long |
getRequestTime()
Gets the request time in milliseconds of the HttpRequest
that resulted in this CachedObject's
HttpResponse. |
HttpResponse |
getResponse()
Gets the HTTP response of this CachedObject. |
String |
getURL()
Gets the URL of this CachedObject. |
boolean |
isFresh()
Determines if this CachedObject is fresh. |
static boolean |
isFresh(long ageValue,
long dateValue,
long requestTime,
long responseTime,
long maxAgeValue,
long expiresValue,
long lastModifiedValue,
long cacheExpirationBuffer)
Determines based upon the specified values if some response is fresh. |
void |
setExpires(long expiresValue)
Convenience method for setting the Expires field value of the containing HttpResponse to the specified
expiresValue. |
void |
setLastAccessed(long lastAccessed)
Sets last accessed time in milliseconds of this CachedObject to the specified
lastAccessed. |
void |
setRequestTime(long requestTime)
Sets the request time in milliseconds of the HttpRequest
that resulted in this CachedObject's
HttpResponse to the specified requestTime. |
void |
setResponse(HttpResponse httpResponse)
Sets the HTTP response of this CachedObject to the
specified httpResponse. |
void |
setURL(String url)
Sets the URL of this CachedObject to the specified
url. |
int |
size()
Gets the approximate size in number of bytes of this CachedObject. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CachedObject(HttpResponse httpResponse,
CacheManager cacheManager)
Constructs a CachedObject with the specified
httpResponse and cacheManager.
httpResponse - the HTTP response of the CachedObject to be
created.cacheManager - the cache manager of the CachedObject to be
created.public CachedObject(CacheManager cacheManager)
Constructs a CachedObject with the specified
cacheManager.
cacheManager - the cache manager of the CachedObject to be
created.CachedObject(HttpResponse, CacheManager)
public CachedObject(HttpResponse httpResponse,
ice.net.HttpSession httpSession)
public CachedObject(ice.net.HttpSession httpSession)
CachedObject(CacheManager).
| Method Detail |
public static long calculateCurrentAge(long ageValue,
long dateValue,
long requestTime,
long responseTime)
Calculates the current age of this CachedObject.
Summary of the current age calculation algorithm:
Legend:
- age_value : is the value of Age header received by the cache
with this response.
- date_value : is the value of the origin server's Date header.
- request_time : is the (local) time when the cache made the request
that resulted in this cached response.
- response_time : is the (local) time when the cache received the
response.
- now : is the current (local) time.
apparent_age = max(0, response_time - date_value);
corrected_received_age = max(apparent_age, age_value);
response_delay = response_time - request_time;
corrected_initial_age = corrected_received_age + response_delay;
resident_time = now - response_time;
current_age = corrected_initial_age + resident_time;
For more complete information about current age calculation, please refer to RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", section 13.2.3 - "Age Calculations".
ageValue - the Age HTTP header field value in a response represented
in milliseconds.dateValue - the Date HTTP header field value in a response
represented in milliseconds.requestTime - the request time in milliseconds.responseTime - the response time in milliseconds.
public static long calculateFreshnessLifetime(long maxAgeValue,
long expiresValue,
long dateValue,
long lastModifiedValue,
long responseTime,
long cacheExpirationBuffer)
Calculates the freshness lifetime of this
CachedObject.
For more complete information about freshness lifetime calculation, please refer to RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", section 13.2.4 - "Expiration Calculation".
maxAgeValue - the max-age directive of the Cache-Control HTTP header
field value in a response represented in milliseconds.expiresValue - the Expires HTTP header field value in a response
represented in milliseconds.dateValue - the Date HTTP header field value in a response
represented in milliseconds.lastModifiedValue - the Last-Modified HTTP header field value in a response
represented in milliseconds.responseTime - the response time in milliseconds.cacheExpirationBuffer - the cache expiration buffer in milliseconds.
HttpResponse.MAX_AGE,
HttpMessage.CACHE_CONTROL,
HttpResponse.EntityBody#EXPIRES,
HttpMessage.DATE,
HttpResponse.EntityBody#LAST_MODIFIEDpublic long getAge()
Gets the age HTTP header field value in milliseconds of this
CachedObject's HttpResponse.
HttpResponse.AGEpublic byte[] getdata()
getResponse().getEntityBody().getBytes().
public long getDate()
Gets the date HTTP header field value in milliseconds of this
CachedObject's HttpResponse.
HttpMessage.DATEpublic long getExpires()
Gets the expires HTTP header field value in milliseconds of this
CachedObject's HttpResponse.
HttpMessage.EntityBody.EXPIRESpublic String[] getHeaderKeys()
Gets all the HTTP header field names of this
CachedObject's HttpResponse.
public String[] getHeaders()
Gets all the HTTP header field values of this
CachedObject's HttpResponse.
public long getLastAccessed()
Gets last accessed time in milliseconds of this
CachedObject.
setLastAccessed(long)public long getLastModified()
Gets the last modified HTTP header field value in milliseconds of this
CachedObject's HttpResponse.
HttpMessage.EntityBody.LAST_MODIFIEDpublic long getMaxAge()
Gets the max-age cache directive of the Cache-Control HTTP header
field value of this CachedObject's
HttpResponse.
HttpMessage.CACHE_CONTROL,
HttpResponse.MAX_AGEpublic long getRecivedAt()
getResponse().getResponseTime().
public long getRequestTime()
Gets the request time in milliseconds of the HttpRequest
that resulted in this CachedObject's
HttpResponse.
That is, the time in milliseconds the HttpRequest was
send.
setRequestTime(long)public HttpResponse getResponse()
Gets the HTTP response of this CachedObject.
setResponse(HttpResponse)public String getURL()
Gets the URL of this CachedObject.
setURL(String)public boolean isFresh()
Determines if this CachedObject is fresh.
The calculation to determine if a response has expired is quite simple:
response_is_fresh = (freshness_lifetime > current_age);
For more complete information about is fresh calculation, please refer to RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", section 13.2.4 - "Expiration Calculation".
true is this CachedObject is fresh,
false if not.isFresh(long, long, long, long, long, long, long, long)
public static boolean isFresh(long ageValue,
long dateValue,
long requestTime,
long responseTime,
long maxAgeValue,
long expiresValue,
long lastModifiedValue,
long cacheExpirationBuffer)
Determines based upon the specified values if some response is fresh.
The calculation to determine if a response has expired is quite simple:
response_is_fresh = (freshness_lifetime > current_age);
For more complete information about is fresh calculation, please refer to RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", section 13.2.4 - "Expiration Calculation".
ageValue - the Age HTTP header field value in a response represented
in milliseconds.dateValue - the Date HTTP header field value in a response
represented in milliseconds.requestTime - the request time in milliseconds.responseTime - the response time in milliseconds.maxAgeValue - the max-age directive of the Cache-Control HTTP header
field value in a response represented in milliseconds.expiresValue - the Expires HTTP header field value in a response
represented in milliseconds.lastModifiedValue - the Last-Modified HTTP header field value in a response
represented in milliseconds.cacheExpirationBuffer - the cache expiration buffer in milliseconds.
true if based upon the specified values the
result is fresh, false if not.calculateFreshnessLifetime(long, long, long, long, long, long),
calculateCurrentAge(long, long, long, long)public void setExpires(long expiresValue)
Convenience method for setting the Expires field value of the
containing HttpResponse to the specified
expiresValue.
expiresValue - the new Expires value.getExpires()public void setLastAccessed(long lastAccessed)
Sets last accessed time in milliseconds of this
CachedObject to the specified
lastAccessed.
lastAccessed - the new last accessed time in milliseconds.getLastAccessed()public void setRequestTime(long requestTime)
Sets the request time in milliseconds of the HttpRequest
that resulted in this CachedObject's
HttpResponse to the specified requestTime.
That is, the time in milliseconds the HttpRequest was
send.
requestTime - the new request time in milliseconds.getRequestTime()public void setResponse(HttpResponse httpResponse)
Sets the HTTP response of this CachedObject to the
specified httpResponse.
httpResponse - the new HTTP response.getResponse()public void setURL(String url)
Sets the URL of this CachedObject to the specified
url.
url - the new URL.getURL()public int size()
Gets the approximate size in number of bytes of this
CachedObject.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||