【问题标题】:Autodesk Viewer double-compressed streamsAutodesk Viewer 双压缩流
【发布时间】:2017-05-30 07:40:38
【问题描述】:

使用 Autodesk Viewer 时收到错误消息:

LMV 资源 ([编辑]/1/objects_attrs.json.gz) 没有被浏览器解压。这会损害性能。检查 服务端返回的 Content-Encoding 头,检查是否 你得到双压缩流。警告仅打印一次 但问题可能会影响多个资源。

我的响应头如下:

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

【问题讨论】:

    标签: autodesk-viewer


    【解决方案1】:

    是的,如果您看到此警告,则查看器正在处理解压缩,这在性能方面是不可取的。

    您能否看看我关于使用代理为您的查看器资源提供服务的文章:Securing your Forge Viewer token behind a proxy

    这为压缩后的资源(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')  
    

    【讨论】:

    • 值得一提的是它从那时起发生了变化。您可以将它与 Autodesk.Viewing.endpoint.setEndpointAndApi 一起使用
    猜你喜欢
    • 2022-01-13
    • 2018-01-04
    • 2020-05-06
    • 2020-01-16
    • 2014-03-31
    • 2021-05-13
    • 2021-01-19
    • 2020-01-06
    • 2011-04-19
    相关资源
    最近更新 更多