Skip to content

Commit

Permalink
actually fixed caching
Browse files Browse the repository at this point in the history
  • Loading branch information
czechboy0 committed Oct 14, 2015
1 parent 0a8d2a4 commit 4790580
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions BuildaUtils/HTTPUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ public class HTTP {

public var session: NSURLSession

public init(session: NSURLSession = NSURLSession.sharedSession()) {
public init(session: NSURLSession?) {

//disable all caching
session.configuration.requestCachePolicy = .ReloadIgnoringCacheData
session.configuration.URLCache = nil

self.session = session
if let session = session {
self.session = session
} else {

let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()

//disable all caching
configuration.requestCachePolicy = NSURLRequestCachePolicy.ReloadIgnoringCacheData
configuration.URLCache = nil

let session = NSURLSession(configuration: configuration)
self.session = session
}
}

public typealias Completion = (response: NSHTTPURLResponse?, body: AnyObject?, error: NSError?) -> ()
Expand Down
2 changes: 1 addition & 1 deletion BuildaUtils/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class HTTPServer : NSObject {
public let http: HTTP

public init(http: HTTP? = nil) {
self.http = http ?? HTTP()
self.http = http ?? HTTP(session: nil)
}
}

0 comments on commit 4790580

Please sign in to comment.