Autodesk Viewer双压缩流

时间:2017-05-29 07:06:45

标签: autodesk-viewer

使用Autodesk Viewer时,我收到错误:

  

LMV资源   ([删除] /1/objects_attrs.json.gz)   没有被浏览器解压缩。这会伤害表现。检查   服务器返回的Content-Encoding标头,检查是否   您正在获得双压缩流。警告只打印一次   但问题可能会影响到多种资源。

我的回复标题如下:

enter image description here

我的回复是否应该有Content-Encoding: gzip标题?当控制台中记录此错误时,Viewer是解压缩文件而不是浏览器吗?

1 个答案:

答案 0 :(得分: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')