Autodesk 查看器 double-compressed 个流
Autodesk Viewer double-compressed streams
使用 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.
我的回复header如下:
我的回复应该有 Content-Encoding: gzip
header 吗?控制台中记录此错误时,是查看器而不是浏览器解压缩文件吗?
是的,如果您看到此警告,查看器正在处理解压缩,这在性能方面是不可取的。
你能看看我关于使用代理为你的查看器资源提供服务的文章吗: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')
使用 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.
我的回复header如下:
我的回复应该有 Content-Encoding: gzip
header 吗?控制台中记录此错误时,是查看器而不是浏览器解压缩文件吗?
是的,如果您看到此警告,查看器正在处理解压缩,这在性能方面是不可取的。
你能看看我关于使用代理为你的查看器资源提供服务的文章吗: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')