         }
     }
 
-    func writeData(data: NSData) {
+    func etagFileNameFromDataFile(dataFileName: String) -> String {
+        return dataFileName + ".etag"
+    }
+
+    func readDataEtag() -> String? {
+        let (dir, _) = dataDir()
+        let path = etagFileNameFromDataFile(dir + "/" + dataFile)
+        if !NSFileManager.defaultManager().fileExistsAtPath(path) {
+            return nil
+        }
+        guard let data = NSFileManager.defaultManager().contentsAtPath(path) else { return nil }
+        return NSString(data: data, encoding: NSUTF8StringEncoding) as? String
+    }
+
+    func writeData(data: NSData, etag: String?) {
         let (dir, wasCreated) = dataDir()
         // If dir existed already, clear out the old one
         if !wasCreated {

        if !data.writeToFile(path, atomically: true) {
            showError("Failed to write data to \(path)")
        }
    }

    func readData() -> NSData? {

                    print(err.localizedDescription)
                    delay(60) {
                        // keep trying every minute until successful
                        networkRequest(forceDownload: force)
                    }
                }
                else {
                    if let data = data, response = response as? NSHTTPURLResponse {
                        let etag = response.allHeaderFields["Etag"] as? String
                        self.writeData(data, etag: etag)
                        AdBlockCppFilter.singleton().setAdblockDataFile(data)
                    }
                }
