         do {
             let attributes = try fileManager.attributesOfItemAtPath(filePath)
             response.setHeader("Cache-Control", value: "max-age=\(maxAgeCacheControlHeader)")
-            if let date = attributes[NSFileModificationDate] as? NSDate where addLastModifiedHeader {
-                response.setHeader("Last-Modified", value: SpiUtils.httpDate(date))
+            if addLastModifiedHeader {
+                if let date = attributes[NSFileModificationDate] as? NSDate {
+                    response.setHeader("Last-Modified", value: SpiUtils.httpDate(date))
+                }
+            }
+            if generateETag {
+                if let date = attributes[NSFileModificationDate] as? NSDate,
+                    let size = attributes[NSFileSize] as? Int {
+                        let sizeHex = String(size, radix: 16, uppercase: false)
+                        let timeHex = String(Int(date.timeIntervalSince1970), radix: 16, uppercase: false)
+                        let etag = "W/\"\(sizeHex)-\(timeHex)\""
+                        response.setHeader("Etag", value: etag)
+                 }
             }
             if let _ = customResponseHeadersSetter {
                 customResponseHeadersSetter!.setCustomResponseHeaders(response, filePath: filePath, fileAttributes: attributes)

        case MaxAgeCacheControlHeader(Int)
        case Redirect(Bool)
        case CustomResponseHeadersSetter(ResponseHeadersSetter)
    }

}

    //
    private var customResponseHeadersSetter : ResponseHeadersSetter?
    
    //
    // Generate ETag. Defaults to true.
    //
    private var generateETag = true
    
    
    
    private var path : String
    
    public convenience init (options: [Options]) {
