https://github.com/irons163/irhttpcache
IRHTTPCache is a powerful media cache framework. It can cache HTTP request, and very suitable for media resources.
https://github.com/irons163/irhttpcache
cache http-cache video-cache
Last synced: 10 months ago
JSON representation
IRHTTPCache is a powerful media cache framework. It can cache HTTP request, and very suitable for media resources.
- Host: GitHub
- URL: https://github.com/irons163/irhttpcache
- Owner: irons163
- License: mit
- Created: 2021-03-30T06:12:26.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-05T09:53:38.000Z (over 4 years ago)
- Last Synced: 2025-02-17T06:35:01.941Z (11 months ago)
- Topics: cache, http-cache, video-cache
- Language: Objective-C
- Homepage:
- Size: 55.4 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# IRHTTPCache
- IRHTTPCache is a copy project from [KTVHTTPCache](https://github.com/ChangbaDevs/KTVHTTPCache).
- IRHTTPCache is a powerful media cache framework. It can cache HTTP request, and very suitable for media resources.
- A usage case is using IRHTTPCache combine with the video player([IRPlayer](https://github.com/irons163/IRPlayer)) for cache.
## Features
- Support Swift.
- Thread safety.
- Logging system, Support for console and file output.
- Accurate view caching information.
- Provide different levels of interface.
- Adjust the download configuration.
- Including demo
- AVPlayer
- ([IRPlayer](https://github.com/irons163/IRPlayer))
## Install
### Git
- Git clone this project.
- Copy this project into your own project.
- Add the .xcodeproj into you project and link it as an embed framework.
- Also, link IRCocoaHTTPServer as an embed framework.
#### Options
- You can remove the `demo` and `ScreenShots` folder.
### Cocoapods
- Add `pod 'IRHTTPCache'` in the `Podfile`
- `pod install`
## Usage
### Swift
```swift
let _: () = { () -> () in
self.setupHTTPCache()
}()
...
func setupHTTPCache() {
IRHTTPCache.logSetConsoleLogEnable(true)
do {
try IRHTTPCache.proxyStart()
NSLog("Proxy Start Success");
} catch {
NSLog("Proxy Start Failure");
}
IRHTTPCache.encodeSetURLConverter { (URL) -> URL? in
NSLog("URL Filter reviced URL")
return URL
}
IRHTTPCache.downloadSetUnacceptableContentTypeDisposer { (URL, contentType) -> Bool in
NSLog("Unsupport Content-Type Filter reviced URL")
return false
}
}
```
- Generated proxy URL.
```swift
IRHTTPCache.proxyURL(withOriginalURL: originalURL)
```
### ObjC
- Start proxy.
```objc
[IRHTTPCache proxyStart:&error];
```
- Generated proxy URL.
```objc
NSURL *proxyURL = [IRHTTPCache proxyURLWithOriginalURL:originalURL];
AVPlayer *player = [AVPlayer playerWithURL:proxyURL];
```
- Get the complete cache file URL if existed.
```objc
NSURL *completeCacheFileURL= [IRHTTPCache cacheCompleteFileURLWithURL:originalURL];
```
- Set the URL filter processing mapping relationship.
```objc
[IRHTTPCache encodeSetURLConverter:^NSURL *(NSURL *URL) {
return URL;
}];
```
- Download Configuration
```objc
// Timeout interval.
[IRHTTPCache downloadSetTimeoutInterval:30];
// Accept Content-Type.
[IRHTTPCache downloadSetAcceptableContentTypes:contentTypes];
// Set unsupport Content-Type filter.
[IRHTTPCache downloadSetUnacceptableContentTypeDisposer:^BOOL(NSURL *URL, NSString *contentType) {
return NO;
}];
// Additional headers.
[IRHTTPCache downloadSetAdditionalHeaders:headers];
// Whitelist headers.
[IRHTTPCache downloadSetWhitelistHeaderKeys:headers];
```
- Log.
```objc
// Console.
[IRHTTPCache logSetConsoleLogEnable:YES];
// File.
[IRHTTPCache logSetRecordLogEnable:YES];
NSString *logFilePath = [IRHTTPCache logRecordLogFilePath];
```
## Screenshots
| Demo Main Page | Demo1 |
|:---:|:---:|
|||