Annotation of libwww/Library/src/HTCache.html, revision 2.7

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.2       frystyk     3: <TITLE>Disk Cache Manager</TITLE>
2.6       frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen, 14-Nov-1995 -->
2.1       frystyk     5: <NEXTID N="z4">
                      6: </HEAD>
                      7: <BODY>
                      8: 
2.2       frystyk     9: <H1>Disk Cache Manager</H1>
2.1       frystyk    10: 
                     11: <PRE>
                     12: /*
                     13: **     (c) COPYRIGHT MIT 1995.
                     14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
                     17: 
                     18: The cache contains details of temporary disk files which contain the
                     19: contents of remote documents.  There is also a <A
                     20: HREF="HTAnchor.html#z1">list of cache items for each URL</A> in its
                     21: anchor object. <P>
                     22: 
                     23: This module is implemented by <A HREF="HTCache.c">HTCache.c</A>, and
2.6       frystyk    24: it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/">W3C
                     25: Reference Library</A>.
2.1       frystyk    26: 
                     27: <PRE>
                     28: #ifndef HTCACHE_H
                     29: #define HTCACHE_H
                     30: 
                     31: #include "HTStream.h"
                     32: #include "HTAnchor.h"
                     33: #include "HTFormat.h"
2.4       frystyk    34: #include "HTReq.h"
2.1       frystyk    35: </PRE>
                     36: 
                     37: <H2>Converters</H2>
                     38: 
                     39: The cache stream is in fact a stream that can be registered as a converter!
                     40: 
                     41: <PRE>
                     42: extern HTConverter HTCacheWriter;
                     43: </PRE>
                     44: 
2.4       frystyk    45: <H3>How do we handle Expires header?</H3>
                     46: 
                     47: There are various ways of handling Expires header when met in a
                     48: history list. Either it can be ignored all together, the user can be
                     49: notified with a warning, or the document can be reloaded
                     50: automatically. This flag decides what action to be taken. The default
                     51: action is HT_EXPIRES_IGNORE. In HT_EXPIRES_NOTIFY mode you can specify
                     52: a message to tell the user (NULL is valid in which case my own message
                     53: pops up - watch out it might be in Danish ;-))
                     54: 
                     55: <PRE>
                     56: typedef enum _HTExpiresMode {
                     57:     HT_EXPIRES_IGNORE = 0,
                     58:     HT_EXPIRES_NOTIFY,
                     59:     HT_EXPIRES_AUTO
                     60: } HTExpiresMode;
                     61: 
                     62: extern void HTCache_setExpiresMode (HTExpiresMode mode, char * notify);
                     63: extern HTExpiresMode HTCache_expiresMode (char ** notify);
                     64: </PRE>
                     65: 
                     66: <A NAME="memcache"><H2>Memory cache Management</H2></A>
                     67: 
                     68: The Library has two notions of a local cache: a file cache and a
                     69: memory cache. The memory cache is handled by the client and the file
                     70: cache is handled by the Library. Often the format of a object cached
                     71: in memory is in the form of a hypertext object ready to be displayed
                     72: (that is, it's already parsed). However, this is not required, and the
                     73: application can therefore register a memory cache handler that returns
                     74: an int with the following values:
                     75: 
                     76: <UL>
                     77: <LI>HT_LOADED if the document is in memory and is OK
                     78: <LI>HT_ERROR if the document is not in memory
                     79: </UL>
                     80: 
                     81: <PRE>
                     82: typedef int HTMemoryCacheHandler       (HTRequest *    request,
                     83:                                         HTExpiresMode  mode,
                     84:                                         char *         message);
                     85: 
                     86: extern int  HTMemoryCache_check                (HTRequest * request);
                     87: extern BOOL HTMemoryCache_register     (HTMemoryCacheHandler * cbf);
                     88: extern BOOL HTMemoryCache_unRegister   (void);
                     89: </PRE>
                     90: 
2.2       frystyk    91: <H2>Find a Reference for a Cached Object</H2>
2.1       frystyk    92: 
2.2       frystyk    93: Verifies if a cache object exists for this URL and if so returns a URL
                     94: for the cached object. It does not verify whether the object is valid
                     95: or not, for example it might have been expired.
2.1       frystyk    96: 
                     97: <PRE>
2.6       frystyk    98: extern char * HTCache_getReference     (char * url);
2.2       frystyk    99: </PRE>
                    100: 
                    101: <H2>Verify if an Object is Valid</H2>
                    102: 
                    103: This function checks whether a document has expired or not.  The check
                    104: is based on the metainformation passed in the anchor object The
                    105: function returns YES or NO.
                    106: 
                    107: <PRE>
2.6       frystyk   108: extern BOOL HTCache_isValid            (HTParentAnchor * anchor);
2.1       frystyk   109: </PRE>
                    110: 
                    111: <H2>Enable Cache</H2>
                    112: 
                    113: If <EM>cache_root</EM> is NULL then reuse old value or use
                    114: <CODE>HT_CACHE_ROOT</CODE>.  An empty string will make '/' as cache
                    115: root.
                    116: 
                    117: <PRE>
2.7     ! frystyk   118: extern BOOL HTCache_enable             (const char * cache_root);
2.1       frystyk   119: </PRE>
                    120: 
                    121: <H2>Disable Cache</H2>
                    122: 
                    123: Turns off the cache. Note that the cache can be disabled and enabled
                    124: at any time. The cache root is kept and can be reused during the
                    125: execution.
                    126: 
                    127: <PRE>
2.6       frystyk   128: extern BOOL HTCache_disable            (void);
2.1       frystyk   129: </PRE>
                    130: 
                    131: <H2>Is Cache Enabled</H2>
                    132: 
                    133: Returns YES or NO. Also makes sure that we have a root value (even
                    134: though it might be invalid)
                    135: 
                    136: <PRE>
2.6       frystyk   137: extern BOOL HTCache_isEnabled          (void);
2.1       frystyk   138: </PRE>
                    139: 
                    140: <H2>Set Cache Root</H2>
                    141: 
                    142: If <EM>cache_root</EM> is NULL then the current value (might be a define)
                    143: Should we check if the cache_root is actually OK? I think not!
                    144: 
                    145: <PRE>
2.7     ! frystyk   146: extern BOOL HTCache_setRoot            (const char * cache_root);
2.1       frystyk   147: </PRE>
                    148: 
                    149: <H2>Get Cache Root</H2>
                    150: 
                    151: <PRE>
2.7     ! frystyk   152: extern const char *HTCache_getRoot     (void);
2.1       frystyk   153: </PRE>
                    154: 
2.2       frystyk   155: <H2>Clean up memory</H2>
2.1       frystyk   156: 
                    157: This is done by the Library function <A
2.4       frystyk   158: HREF="HTReq.html#Library">HTLibTerminate()</A>. None of these
2.2       frystyk   159: functions tourches the disk cache itself - they only manages memory.
2.1       frystyk   160: 
                    161: <PRE>
2.6       frystyk   162: extern void HTCache_freeRoot           (void);
                    163: extern void HTCache_clearMem           (void);
2.1       frystyk   164: </PRE>
                    165: 
2.2       frystyk   166: <H2>To remove All cache files known to this session</H2>
2.1       frystyk   167: 
2.2       frystyk   168: This function also cleans the entries on disk
2.1       frystyk   169: 
                    170: <PRE>
2.6       frystyk   171: extern void HTCache_deleteAll          (void);
2.1       frystyk   172: 
                    173: #endif
                    174: </PRE>
                    175: 
                    176: End of declaration module
                    177: </BODY>
                    178: </HTML>

Webmaster