2
votes

I try enable GZip compression for improve connection performance between client and server, but it seems that WebView doesn't decompress GZip-response.

Response Header(from server) contains: Content-Encoding:gzip Content-Type:application/gzip

Body contains compressed JSON

On the Desktop browsers all fine, but if it is android device in Chrome DevTools I see compressed body. Mobile app doesn't decompress response body.

Created issue https://issues.apache.org/jira/browse/CB-9427

1
the android mobile webview and browsers are no where near desktop browsers, they probably just don't support it. I don't know for sure but that is my best guess. That is why on android I build all of my apps with crosswalk. has support for everything and blows performance through the roof: crosswalk-project.orgJess Patton

1 Answers

2
votes

When I have changed content type into 'application/json' problem was solved.

Here sample from Grape framework app:

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

Issue https://issues.apache.org/jira/browse/CB-9427 was closed.

Thanks to cordova support team!