Ben Copsey

Added comments explaining cache policy options

@@ -9,17 +9,40 @@ @@ -9,17 +9,40 @@
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 @class ASIHTTPRequest; 10 @class ASIHTTPRequest;
11 11
  12 +// Cache policies control the behaviour of a cache and how requests use the cache
  13 +// When setting a cache policy, you can use a combination of these values as a bitmask
  14 +// For example: [request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy|ASIDoNotWriteToCacheCachePolicy];
  15 +// Note that some of the behaviours below are mutally exclusive - you cannot combine ASIAskServerIfModifiedWhenStaleCachePolicy and ASIAskServerIfModifiedCachePolicy, for example.
12 typedef enum _ASICachePolicy { 16 typedef enum _ASICachePolicy {
  17 +
  18 + // The default cache policy. When you set a request to use this, it will use the cache's defaultCachePolicy
  19 + // ASIDownloadCache's default cache policy is 'ASIAskServerIfModifiedWhenStaleCachePolicy'
13 ASIUseDefaultCachePolicy = 0, 20 ASIUseDefaultCachePolicy = 0,
  21 +
  22 + // Tell the request not to read from the cache
14 ASIDoNotReadFromCacheCachePolicy = 1, 23 ASIDoNotReadFromCacheCachePolicy = 1,
  24 +
  25 + // The the request not to write to the cache
15 ASIDoNotWriteToCacheCachePolicy = 2, 26 ASIDoNotWriteToCacheCachePolicy = 2,
  27 +
  28 + // Ask the server if there is an updated version of this resource (using a conditional GET) ONLY when the cached data is stale
16 ASIAskServerIfModifiedWhenStaleCachePolicy = 4, 29 ASIAskServerIfModifiedWhenStaleCachePolicy = 4,
  30 +
  31 + // Always ask the server if there is an updated version of this resource (using a conditional GET)
17 ASIAskServerIfModifiedCachePolicy = 8, 32 ASIAskServerIfModifiedCachePolicy = 8,
  33 +
  34 + // If cached data exists, use it even if it is stale. This means requests will not talk to the server unless the resource they are requesting is not in the cache
18 ASIOnlyLoadIfNotCachedCachePolicy = 16, 35 ASIOnlyLoadIfNotCachedCachePolicy = 16,
  36 +
  37 + // If cached data exists, use it even if it is stale. If cached data does not exist, stop (will not set an error on the request)
19 ASIDontLoadCachePolicy = 32, 38 ASIDontLoadCachePolicy = 32,
  39 +
  40 + // Specifies that cached data may be used if the request fails. If cached data is used, the request will succeed without error. Usually used in combination with other options above.
20 ASIFallbackToCacheIfLoadFailsCachePolicy = 64 41 ASIFallbackToCacheIfLoadFailsCachePolicy = 64
21 } ASICachePolicy; 42 } ASICachePolicy;
22 43
  44 +// Cache storage policies control whether cached data persists between application launches (ASICachePermanentlyCacheStoragePolicy) or not (ASICachePermanentlyCacheStoragePolicy)
  45 +// Calling [ASIHTTPRequest clearSession] will remove any data stored using ASICacheForSessionDurationCacheStoragePolicy
23 typedef enum _ASICacheStoragePolicy { 46 typedef enum _ASICacheStoragePolicy {
24 ASICacheForSessionDurationCacheStoragePolicy = 0, 47 ASICacheForSessionDurationCacheStoragePolicy = 0,
25 ASICachePermanentlyCacheStoragePolicy = 1 48 ASICachePermanentlyCacheStoragePolicy = 1