Web worker won't start in IE unless the cache

2019-03-20 03:26发布

I'm having a really weird bug in my HTML5 script. I wrote a sharepoint app completely in OData which uses a few HTML 5 webworker to do the number crunching in the background. This works perfect on all major browsers (FF, IE10+ Chrome, ...). However, when I perform a refresh or browse to the page again. The script still works as intended on FF and Chrome, but hangs on IE.

In my network view I see a request for the Worker.js file, but with a 304 NOT MODIFIED response. IE then just hangs there on that request with a status of (Pending). This issue only gets resolved when I clear my browser cache.

I correctly close all my threads with self.close().

Any idea what the issue could be? I'm not sure if it's a code issue, a browser issue or a server side issue but I can replicate the bug on Sharepoint online as well as on a local server. The whole project is JS only, so I can't modify headers as a workaround either.

UPDATE: I ran exactly the same code outside of a sharepoint environment, and it worked perfectly. Issue is Sharepoint related.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-20 03:41

SharePoint sends the header:

Content-Disposition: attachment; filename="xyz.js"
X-Download-Options:  noopen

and the IE Web Worker Implantation then does not run this web worker. (Tested in IE11) In the IE Network Monitor the request still on pending, even the Response text is visible.

I know so fare two workarounds:

  1. Place the web worker js in the layouts folder (needs a Farm Solution, with the downside of this)
  2. Set the Browser File Handling for the Web application to Permissive (maybe your security is not amused)
查看更多
【Aperson】
3楼-- · 2019-03-20 03:54

using a time based querystring parameter prevents caching showing http status 200 on each refresh. tested on latest chrome, ie, ff;

var opus = new Worker("worker.js?q=" + new Date().getTime().toString() );

to be honest this a long shot as i do not have sharepoint right now

查看更多
登录 后发表回答