artifacts / AFCache

AFCache is an HTTP cache for iOS and OSX seeking towards full RFC2616 compliance
Apache License 2.0
361 stars 43 forks source link

Current Version

0.9.10

Current active branch

develop

What is AFCache?

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.

Goals

Sounds like something I need. Where can I get documentation?

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.

History

API

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.

Project status

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.

Branches

Outdated:

Logging

Logging is achieved via an AFLog macro which is either

Issues (Open)

Issues (Done)

Anatomy of the manifest file

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.

Example:

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"

Anatomy of the package zip file

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.

Build notes when using AFCache in your project

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

How to run the unit tests (outdated)

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

Copyright 2008, 2009, 2010, 2011, 2012, 2013 Artifacts - Fine Software Development

http://www.artifacts.de

Authors: Michael Markowski (m.markowski@artifacts.de) Lars Blumberg Sebastian Grimme Claus Weymann

Nico Schmidt (Savoy Software) Björn Kriews (bkr (0x40) jumper.org) Christian Menschel (post at cmenschel.de)

License

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.