{"id":13849291,"url":"https://github.com/rs/SDURLCache","last_synced_at":"2025-07-12T16:31:29.378Z","repository":{"id":62453503,"uuid":"564730","full_name":"rs/SDURLCache","owner":"rs","description":"URLCache subclass with on-disk cache support on iPhone/iPad","archived":false,"fork":false,"pushed_at":"2017-04-03T04:56:56.000Z","size":59,"stargazers_count":798,"open_issues_count":20,"forks_count":246,"subscribers_count":38,"default_branch":"master","last_synced_at":"2024-11-21T22:04:35.252Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-03-16T09:16:25.000Z","updated_at":"2024-10-29T15:47:44.000Z","dependencies_parsed_at":"2022-11-02T00:01:05.265Z","dependency_job_id":null,"html_url":"https://github.com/rs/SDURLCache","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2FSDURLCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2FSDURLCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2FSDURLCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2FSDURLCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rs","download_url":"https://codeload.github.com/rs/SDURLCache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225809025,"owners_count":17527426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T19:01:13.246Z","updated_at":"2024-11-22T01:30:45.207Z","avatar_url":"https://github.com/rs.png","language":"Objective-C","readme":"On iPhone OS, Apple did remove on-disk cache support for unknown reason. Some will say it's to save\nflash-drive life, others will arg it's to save disk capacity. As it is explained in the\nNSURLCacheStoragePolicy, the NSURLCacheStorageAllowed constant is always treated as\nNSURLCacheStorageAllowedInMemoryOnly and there is no way to force it back, the code is certainly\ngone on this platform. For whatever reason Apple removed this feature, you may be interested by\nhaving on-disk HTTP request caching in your application. SDURLCache gives back this feature to this\niPhone OS for you.\n\nTo use it, you just have create an instance, replace the default shared NSURLCache with it and\nthat's it, you instantly give on-disk HTTP request caching capability to your application.\n\n    SDURLCache *urlCache = [[SDURLCache alloc] initWithMemoryCapacity:1024*1024   // 1MB mem cache\n                                                         diskCapacity:1024*1024*5 // 5MB disk cache\n                                                             diskPath:[SDURLCache defaultCachePath]];\n    [NSURLCache setSharedURLCache:urlCache];\n    [urlCache release];\n\nTo save flash drive, SDURLCache doesn't cache on disk responses if cache expiration delay is lower\nthan 5 minutes by default. You can change this behavior by changing the `minCacheInterval` property.\n\nCache eviction is done automatically when disk capacity is reached in a periodic maintenance\nthread. All disk write operations are done in a separated thread so they can't block the main run\nloop.\n\nTo control the caching behavior, use the `NSURLRequest`'s `cachePolicy` property. If you want a\nresponse not to be cached on disk but still in memory, you can implement the `NSURLConnection`\n`connection:willCacheResponse:` delegate method and change the `NSURLCachedResponse` `storagePolicy`\nproperty to `NSURLCacheStorageAllowedInMemoryOnly`. See example below:\n\n    - (NSCachedURLResponse *)connection:(NSURLConnection *)connection\n                      willCacheResponse:(NSCachedURLResponse *)cachedResponse\n    {\n        NSCachedURLResponse *memOnlyCachedResponse =\n            [[NSCachedURLResponse alloc] initWithResponse:cachedResponse.response\n                                                     data:cachedResponse.data\n                                                 userInfo:cachedResponse.userInfo\n                                            storagePolicy:NSURLCacheStorageAllowedInMemoryOnly];\n        return [memOnlyCachedResponse autorelease];\n    }\n","funding_links":[],"categories":["Objective-C","etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frs%2FSDURLCache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frs%2FSDURLCache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frs%2FSDURLCache/lists"}