public class HTTPCache extends Object
Modifier and Type | Field | Description |
---|---|---|
protected static String |
FILE_EXT_HEADERS |
The file extension for header files (
".headers" ) |
protected static String |
FILE_EXT_VARY |
The file extension for varation-info files (
".vary" ) |
protected static String |
HEADER_CACHE_CONTROL |
The HTTP header
"Cache-Control" |
protected static String |
HEADER_CACHED_TIME |
HTTP extension header
"X-Cached-At" |
protected static String |
HEADER_CONTENT_TYPE |
The HTTP header
"Content-Type" |
protected static String |
HEADER_DATE |
The HTTP header
"Date" |
protected static String |
HEADER_ETAG |
The HTTP header
"ETag" |
protected static String |
HEADER_EXPIRES |
The HTTP header
"Expires" |
protected static String |
HEADER_IF_MODIFIED_SINCE |
The HTTP header
"If-Modified-Since" |
protected static String |
HEADER_IF_NONE_MATCH |
The HTTP header
"If-None-Match" |
protected static String |
HEADER_LAST_MODIFIED |
The HTTP header
"Last-Modified" |
protected static String |
HEADER_PRAGMA |
The HTTP header
"Pragma" |
protected static String |
HEADER_VARY |
The HTTP header
"Vary" |
protected static String |
HEADER_WARNING |
The HTTP header
"Warning" |
Modifier | Constructor | Description |
---|---|---|
|
HTTPCache(File pTempFolder,
long pDefaultCacheExpiryTime,
int pMaxMemCacheSize,
int pMaxCachedEntites,
boolean pDeleteCacheOnExit) |
Creates an
HTTPCache . |
protected |
HTTPCache(File pTempFolder,
long pDefaultCacheExpiryTime,
int pMaxMemCacheSize,
int pMaxCachedEntites,
boolean pDeleteCacheOnExit,
Logger pLogger) |
|
|
HTTPCache(String pName,
javax.servlet.ServletContext pContext,
int pDefaultCacheExpiryTime,
int pMaxMemCacheSize,
int pMaxCachedEntites,
boolean pDeleteCacheOnExit) |
Deprecated.
Use
HTTPCache(File, long, int, int, boolean) instead. |
Modifier and Type | Method | Description |
---|---|---|
void |
doCached(CacheRequest pRequest,
CacheResponse pResponse,
ResponseResolver pResolver) |
Looks up the
CachedEntity for the given request. |
protected File |
getRealFile(CacheRequest pRequest) |
Allows a server-side cache mechanism to peek at the real file.
|
protected void |
invalidate(CacheRequest pRequest) |
|
String |
toString() |
protected static final String HEADER_CACHE_CONTROL
"Cache-Control"
protected static final String HEADER_CONTENT_TYPE
"Content-Type"
protected static final String HEADER_DATE
"Date"
protected static final String HEADER_ETAG
"ETag"
protected static final String HEADER_EXPIRES
"Expires"
protected static final String HEADER_IF_MODIFIED_SINCE
"If-Modified-Since"
protected static final String HEADER_IF_NONE_MATCH
"If-None-Match"
protected static final String HEADER_LAST_MODIFIED
"Last-Modified"
protected static final String HEADER_PRAGMA
"Pragma"
protected static final String HEADER_VARY
"Vary"
protected static final String HEADER_WARNING
"Warning"
protected static final String HEADER_CACHED_TIME
"X-Cached-At"
protected static final String FILE_EXT_HEADERS
".headers"
)protected static final String FILE_EXT_VARY
".vary"
)protected HTTPCache(File pTempFolder, long pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit, Logger pLogger)
public HTTPCache(File pTempFolder, long pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit)
HTTPCache
.pTempFolder
- the temp folder for this cache.pDefaultCacheExpiryTime
- Default expiry time for cached entities,
>= 0
pMaxMemCacheSize
- Maximum size of in-memory cache for content
in bytes, >= 0
(0
means no
in-memory cache)pMaxCachedEntites
- Maximum number of entities in cachepDeleteCacheOnExit
- specifies wether the file cache should be
deleted when the application or VM shuts downIllegalArgumentException
- if pName
or pContext
is
null
or if any of pDefaultCacheExpiryTime
,
pMaxMemCacheSize
or pMaxCachedEntites
are
negative,
or if the directory as given in the context attribute
"javax.servlet.context.tempdir"
does not exist, and
cannot be created.public HTTPCache(String pName, javax.servlet.ServletContext pContext, int pDefaultCacheExpiryTime, int pMaxMemCacheSize, int pMaxCachedEntites, boolean pDeleteCacheOnExit)
HTTPCache(File, long, int, int, boolean)
instead.HTTPCache
.pName
- Name of this cache (should be unique per application).
Used for temp folderpContext
- Servlet context for the application.pDefaultCacheExpiryTime
- Default expiry time for cached entities,
>= 0
pMaxMemCacheSize
- Maximum size of in-memory cache for content
in bytes, >= 0
(0
means no
in-memory cache)pMaxCachedEntites
- Maximum number of entities in cachepDeleteCacheOnExit
- specifies wether the file cache should be
deleted when the application or VM shuts downIllegalArgumentException
- if pName
or pContext
is
null
or if any of pDefaultCacheExpiryTime
,
pMaxMemCacheSize
or pMaxCachedEntites
are
negative,
or if the directory as given in the context attribute
"javax.servlet.context.tempdir"
does not exist, and
cannot be created.public void doCached(CacheRequest pRequest, CacheResponse pResponse, ResponseResolver pResolver) throws IOException, CacheException
CachedEntity
for the given request.pRequest
- the requestpResponse
- the responsepResolver
- the resolverIOException
- if an I/O error occursCacheException
- if the cached entity can't be resolved for some reasonprotected void invalidate(CacheRequest pRequest)
protected File getRealFile(CacheRequest pRequest)
null
.pRequest
- the requestnull
, alwaysCopyright © 2018. All rights reserved.