2017-05-29 65 views
0

当使用Autodesk浏览器,我收到的错误:欧特克浏览器的双压缩流

An LMV resource ([redacted]/1/objects_attrs.json.gz) was not uncompressed by the browser. This hurts performance. Check the Content-Encoding header returned by the server and check whether you're getting double-compressed streams. The warning prints only once but it's likely the problem affects multiple resources.

我的响应头如下:

enter image description here

如果我的回答有一个Content-Encoding: gzip头?在控制台中记录此错误时,Viewer是否解压缩文件而不是浏览器?

回答

1

是的,如果您看到此警告,观众正在处理解压缩,这在性能方面并不理想。

你可以看看我的有关使用代理服务器来服务你的观众资源的文章:Securing your Forge Viewer token behind a proxy

此设置内容编码正确的gzip压缩资源(node.js的代码):

function fixContentHeaders (req, res) { 

    // DS does not return content-encoding header 
    // for gzip and other files that we know are gzipped, 
    // so we add it here. The viewer does want 
    // gzip files uncompressed by the browser 
    if (EXTENSIONS.gzip.indexOf (path.extname (req.path)) > -1) { 
    res.set ('content-encoding', 'gzip') 
    } 

    if (EXTENSIONS.json.indexOf (path.extname (req.path)) > -1){ 
    res.set ('content-type', 'application/json') 
    } 
} 

此外,您还可以直接从衍生服务提供文件:

//This API available from v 2.14 
Autodesk.Viewing.setEndpointAndApi( 
    window.location.origin + '/lmv-proxy', 
'modelDerivativeV2')