/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */
The cache contains details of persietent files which contain the contents of remote documents. The existing cache manager is somewhat naive - especially in its garbage collection but it is just an example of how it can be done. More advanced implementations are welcome!
This module is implemented by HTCache.c, and it is a part of the W3C Reference Library.
#ifndef HTCACHE_H #define HTCACHE_H #include "WWWLib.h"
The persistent cache has a set of overall parameters that you can adust
If cache_root is NULL then reuse old value or use
HT_CACHE_ROOT
. An empty string will make '/' as cache root.
extern BOOL HTCache_enable (const char * cache_root);
Turns off the cache. Note that the cache can be disabled and enabled at any time. The cache root is kept and can be reused during the execution.
extern BOOL HTCache_disable (void);
Returns YES or NO. Also makes sure that we have a root value (even though it might be invalid)
extern BOOL HTCache_isEnabled (void);
If cache_root is NULL then the current value (might be a define) Should we check if the cache_root is actually OK? I think not!
extern BOOL HTCache_setRoot (const char * cache_root); extern const char *HTCache_getRoot (void);
This is normally done automatically by the Lib object. None of these functions touches the disk cache itself - they only manages memory.
extern void HTCache_freeRoot (void); extern void HTCache_clearMem (void);
You can also prune the cache sompletely including the file objects.
extern void HTCache_deleteAll (void);
This function checks whether a document has expired or not. The check is
based on the metainformation passed in the anchor object The function returns
YES
or NO
.
extern BOOL HTCache_isValid (HTParentAnchor * anchor);
There are various ways of handling Expires
header when met in
a history list. Either it can be ignored all together, the user can be notified
with a warning, or the document can be reloaded automatically. This flag
decides what action to be taken. The default action is
HT_EXPIRES_IGNORE
. In HT_EXPIRES_NOTIFY
mode ,
we push a message on to the Error stack which is presented to the user.
typedef enum _HTExpiresMode { HT_EXPIRES_IGNORE = 0, HT_EXPIRES_NOTIFY, HT_EXPIRES_AUTO } HTExpiresMode; extern void HTCache_setExpiresMode (HTExpiresMode mode); extern HTExpiresMode HTCache_expiresMode (void);
Filling the cache is done as all other transportation of bulk data in libwww using streams. The cache object creater is a stream which in many cases sits on a T stream so that we get the original feed and at the same time can parse the contents.
extern HTConverter HTCacheWriter;
Verifies if a cache object exists for this URL and if so returns a URL for the cached object. It does not verify whether the object is valid or not, for example it might have expired. Use the cache validation methods for checking this.
extern char * HTCache_getReference (char * url);
#endif