Android Cordova GZip解压不';行不通

Android Cordova GZip解压不';行不通,android,cordova,http,gzip,ionic,Android,Cordova,Http,Gzip,Ionic,我尝试启用GZip压缩以提高客户端和服务器之间的连接性能,但WebView似乎没有解压缩GZip响应 响应头(来自服务器)包含: 内容编码:gzip 内容类型:应用程序/gzip 正文包含压缩的JSON 在桌面浏览器上,一切正常, 但如果是ChromeDevTools中的android设备,我会看到压缩的机身。 移动应用程序不会解压缩响应体 当我将内容类型更改为“application/json”时创建的问题解决了 这里是Grape framework应用程序的示例: module App

我尝试启用GZip压缩以提高客户端和服务器之间的连接性能,但WebView似乎没有解压缩GZip响应

响应头(来自服务器)包含: 内容编码:gzip 内容类型:应用程序/gzip

正文包含压缩的JSON

在桌面浏览器上,一切正常, 但如果是ChromeDevTools中的android设备,我会看到压缩的机身。 移动应用程序不会解压缩响应体


当我将内容类型更改为“application/json”时创建的问题解决了

这里是Grape framework应用程序的示例:

module App
  class Users < API

    resource :users do
      format :json
      content_type :txt, "application/json"
      parser :json, nil

      desc "Get users"
      params do
        optional :role, type: String, desc: "User's role"
      end

      get '/all' do
        users = User.all
        path = "#{Rails.root.to_s}/tmp/user_response.gz"
        FileUtils.rm_rf(path, secure: true)
        Zlib::GzipWriter.open(path){|gz| gz.write(users.to_json) }
        content_type "application/json"
        header['Content-Encoding'] = 'gzip';
        env['api.format'] = :json
        File.open(path).read
      end
    end
  end
end
模块应用程序
类用户
问题已经解决


感谢cordova支持团队

android mobile webview和浏览器与桌面浏览器没有任何相似之处,它们可能只是不支持它。我不确定,但这是我最好的猜测。这就是为什么我在android上用crosswalk构建所有应用程序的原因。具有对一切的支持,并将性能提升到极致: