2017-05-29 39 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')