|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.htmlunit.Cache
public class Cache
Simple cache implementation.
The current implementation's main purpose is to provide the ability to cache .js files.
Constructor Summary | |
---|---|
Cache()
|
Method Summary | |
---|---|
void |
cacheIfNeeded(WebRequestSettings request,
WebResponse response)
Cache the response if needed. |
protected void |
deleteOverflow()
Truncates the cache to the maximal number of entries. |
WebResponse |
getCachedContent(WebRequestSettings request)
Returns the cached content corresponding to the specified request. |
int |
getMaxSize()
Returns the cache's maximum size. |
int |
getSize()
Returns the number of entries in the cache. |
protected boolean |
isCacheable(WebRequestSettings request,
WebResponse response)
Determines if the response should be cached. |
protected boolean |
isDynamicContent(WebResponse response)
Tries to guess if the content is dynamic or not. |
protected boolean |
isJavaScript(WebResponse webResponse)
Indicates if the provided response is JavaScript content. |
protected Date |
parseDateHeader(WebResponse response,
String headerName)
Parses and returns the specified date header of the specified response. |
void |
setMaxSize(int maxSize)
Sets the cache's maximum size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Cache()
Method Detail |
---|
public void cacheIfNeeded(WebRequestSettings request, WebResponse response)
request
- the requestresponse
- the responseprotected void deleteOverflow()
protected boolean isCacheable(WebRequestSettings request, WebResponse response)
request
- the performed requestresponse
- the received response
true
if the response should be cachedprotected boolean isDynamicContent(WebResponse response)
Tries to guess if the content is dynamic or not.
"Since origin servers do not always provide explicit expiration times, HTTP caches typically assign heuristic expiration times, employing algorithms that use other header values (such as the Last-Modified time) to estimate a plausible expiration time".
The current implementation considers as dynamic content everything except responses with a Last-Modified header with a date older than 10 minutes or with an Expires header specifying expiration in more than 10 minutes.
response
- the response to examine
true
if the response should be considered as dynamic and therefore uncacheableprotected Date parseDateHeader(WebResponse response, String headerName)
response
- the responseheaderName
- the header name
protected boolean isJavaScript(WebResponse webResponse)
webResponse
- the response to analyze
true
if it can be considered as JavaScriptpublic WebResponse getCachedContent(WebRequestSettings request)
request
- the request whose cached content is sought
public int getMaxSize()
public void setMaxSize(int maxSize)
maxSize
- the cache's maximum size (must be >= 0)public int getSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |