AFCache is an HTTP disk cache for use on iPhone/iPad and OSX. It can be linked as a static library or as a framework. The cache was initially written because on iOS, NSURLCache ignores NSURLCacheStorageAllowed and instead treats it as NSURLCacheStorageAllowedInMemoryOnly which is pretty useless for a persistent cache.
Good question ;) Documentation is always lacking, but you may check the FAQ first. In the AFCache-iOS Xcode-project you'll find example controllers that use AFCache in different ways.
See CHANGES for release notes.
The API has changed from master to branch bip, but it should be easy to migrate. The old master branch moved to branch "pre0.7", but I strongly suggest you to move ahead and migrate to the new master.
AFCache is used in several iPhone applications in several versions. It is constantly evolving and therefore considered beta.
Done: Currently I am doing some major changes and additions like a packaging tool and testing it on two large real-world projects (iPhone and OSX apps). Done: After sucessfully integrating AFCache into these projects I'll extend the demos and some documentation to make it a useful library for the public. The test cases are (still) not maintained very well.
Logging is achieved via an AFLog macro which is either
just a replacement for NSLog (or nothing if undef'd)
a logpoint for EngineRoom, a sophisticated logging framework that enables dynamic logging manipulation at runtime, From the EngineRoom docs: The basic idea is to make the log message a first class citizen. LogPoints are data structures which can be manipulated (i.e. enabled / disabled) at runtime. This is achieved by creating static structures in a separate linker segment.
You may checkout EngineRoom here (https://github.com/bkrpub/EngineRoom) and link AFCache against it by defining USE_ENGINEROOM and adding EngineRoom-OSX.xcodeproj to your project.
The manifest.afcache file contains an entry for every file contained in the archive. One entry looks like this:
URL ; last-modified ; expires\n ; mimetype
Note the delimiter, which is " ; " (space semicolon space) The mimetype is optional.
http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png ; Sat, 27 Mar 2004 18:43:30 GMT+00:00 ; Thu, 29 Jul 2010 14:17:20 GMT+00:00 ; text/html
The URL MUST ne properly encoded and MUST NOT contain a hash at the end or parameters.
Since the file path is calculated based on the URL, it's not necessary to include it in the manifest file. The dates have to be formatted according to rfc1123. Example: "Wed, 01 Mar 2006 12:00:00 GMT"
The zip file structure resembles the URL:
hostname/path/to/file.suffix The zip file contains all files collected by the packager and the manifest file. Optionally, it includes userdata.
You need to link to SystemConfiguration.framework and libz.dylib to compile. Since AFCache uses Objective-C Categories, you need to add the following options to the linker (Targets/YourProject, Info, Build Settings: "Other linker flags") -ObjC -all_load
For more information see: http://developer.apple.com/mac/library/qa/qa2006/qa1490.html
The unit tests currently depend on an existing HTTP-Server e.g. Apache. A simple php script is provided to answer the requests properly. Put the script on your htdocs directory and configure the URL in LogicTests.m, e.g.
static NSString *kBaseURL = @"http://127.0.0.1/~mic/afcache/";
For more information see CHANGES.
I am frequently using Charles as an HTTP debugging proxy which is superb for finding irregularities. http://www.charlesproxy.com/
Copyright 2008, 2009, 2010, 2011, 2012, 2013 Artifacts - Fine Software Development
Authors: Michael Markowski ([email protected]) Lars Blumberg Sebastian Grimme Claus Weymann
Nico Schmidt (Savoy Software) Björn Kriews (bkr (0x40) jumper.org) Christian Menschel (post at cmenschel.de)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.