ASIDownloadCache.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // ASIDownloadCache.h
  3. // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
  4. //
  5. // Created by Ben Copsey on 01/05/2010.
  6. // Copyright 2010 All-Seeing Interactive. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ASICacheDelegate.h"
  10. @interface ASIDownloadCache : NSObject <ASICacheDelegate> {
  11. // The default cache policy for this cache
  12. // Requests that store data in the cache will use this cache policy if their cache policy is set to ASIUseDefaultCachePolicy
  13. // Defaults to ASIAskServerIfModifiedWhenStaleCachePolicy
  14. ASICachePolicy defaultCachePolicy;
  15. // The directory in which cached data will be stored
  16. // Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory
  17. NSString *storagePath;
  18. // Mediates access to the cache
  19. NSRecursiveLock *accessLock;
  20. // When YES, the cache will look for cache-control / pragma: no-cache headers, and won't reuse store responses if it finds them
  21. BOOL shouldRespectCacheControlHeaders;
  22. }
  23. // Returns a static instance of an ASIDownloadCache
  24. // In most circumstances, it will make sense to use this as a global cache, rather than creating your own cache
  25. // To make ASIHTTPRequests use it automatically, use [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];
  26. + (id)sharedCache;
  27. // A helper function that determines if the server has requested data should not be cached by looking at the request's response headers
  28. + (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request;
  29. // A list of file extensions that we know won't be readable by a webview when accessed locally
  30. // If we're asking for a path to cache a particular url and it has one of these extensions, we change it to '.html'
  31. + (NSArray *)fileExtensionsToHandleAsHTML;
  32. @property (assign, nonatomic) ASICachePolicy defaultCachePolicy;
  33. @property (retain, nonatomic) NSString *storagePath;
  34. @property (atomic, retain) NSRecursiveLock *accessLock;
  35. @property (atomic, assign) BOOL shouldRespectCacheControlHeaders;
  36. @end