offline application cache doesnt work in osx webview

I posted this on stack overflow, but repeating here:

http://stackoverflow.com/questions/37016873/offline-application-cache-support-in-mac-os-x-embedded-webkit-webview


I am writing OS X HTML5 app which has to function both online and offline. Offline application cache was prototyped based on the manifest file example.manifest contains:

CACHE MANIFEST # ver 1 CACHE:

When i view this page in Safari, the page loads, and the manifest is read. If i quit safari, go offline, then start Safari and refresh this page, it loads from cache. the offline cache here seems to work fine.

when i repeat this with web view, in Xcode 7.3 Mac OS 10.11, using the following code (storyboard has a web view in a view controller inside of the window):

class ViewController: NSViewController { @IBOutlet var webview: WebView! let THEURL:String = "http:/ override func viewDidLoad() { super.viewDidLoad() let url = NSURL(string: THEURL) let request = NSURLRequest(URL: url!, cachePolicy:NSURLRequestCachePolicy.UseProtocolCachePolicy ,timeoutInterval: 10) webview.mainFrame.loadRequest(request) } }

In the web view case, the page loads fine, but after quitting and restarting offline, the page fails to load. looking at the network traffic, it is clear that the manifest file is never requested from the client. I have tried all of the different cache policies without success. I have also tried creating my own shared URL cache as has been suggested elsewhere with no success.

  let cacheSizeMemory:Int = 4*1024*1024; / let cacheSizeDisk:Int = 32*1024*1024; / let sharedCache:NSURLCache = NSURLCache(memoryCapacity:cacheSizeMemory, diskCapacity:cacheSizeDisk, diskPath:"nsurlcache") NSURLCache.setSharedURLCache(sharedCache)

My questions:

1) does webkit webview in OS X support offline application cache as described in html5? Does WKWebview implement offline cache? Are there other solutions?

2) if yes, what has to be done to make it work?

My workaround is to implement a subclass of NSURLProtocol that implements custom caching and doing the loading logic (offline vs. online) in the app. I would much rather use the standard approach if at all possible.

offline application cache doesnt work in osx webview
 
 
Q