         buildQueue.maxConcurrentOperationCount = 1
         searchQueue.name = "AlgoliaSearch-Search"
         searchQueue.maxConcurrentOperationCount = 1
-        rootDataDir = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).first! + "/algolia"
+        rootDataDir = NSSearchPathForDirectoriesInDomains(.ApplicationSupportDirectory, .UserDomainMask, true).first! + "/algolia"
         super.init(appID: appID, apiKey: apiKey)
         headers["User-Agent"] = headers["User-Agent"]! + ";AlgoliaSearchOfflineCore-iOS \(sdk.versionString)"
     }

    /// - parameter licenseData: license for Algolia's SDK
    ///
    @objc public func enableOfflineMode(licenseData: String) {
        // Create the data directory.
        do {
            try NSFileManager.defaultManager().createDirectoryAtPath(self.rootDataDir, withIntermediateDirectories: true, attributes: nil)
        } catch _ {
            NSLog("Error: could not create cache directory '%@'", self.rootDataDir)
        }
        
        // Init the SDK.
        sdk.initWithLicenseData(licenseData)
        // TODO: Report any error.
    }

    /// Create a new index.

    var sdk: ASSdk = ASSdk.sharedSdk()

    /// Path to directory where the local data is stored.
    /// Defaults to an `algolia` sub-directory inside the `Library/Application Support` directory.
    /// If you set it to another value, do so *before* calling `enableOfflineMode()`.
    ///
    /// WARNING: This directory will be explicitly excluded from iCloud/iTunes backup.
    ///
    @objc public var rootDataDir: String
    
