如何了解网站正在使用gzip压缩? [英] How to understand a website is using gzip compression?

查看:63
本文介绍了如何了解网站正在使用gzip压缩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检查是否有任何网站正在使用gzip?

I am trying to check any website is using gzip or not?

我在Nibbler上找到了这种解释,

I found this explanation on Nibbler,

我们检查页面是否使用GZIP压缩来缩小页面尺寸,以及更快的下载

We check if pages use GZIP compression for smaller page sizes and faster downloading

html中是否有任何显示gzip被使用的内容?我怎么能理解?

Is there anything in html that shows gzip is used? How can I understand that?

推荐答案

URL uri = new URL(url);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestProperty("Accept-Encoding","gzip");
Map<String, List<String>> map = connection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
    System.out.println("Key : " + entry.getKey() +
        " ,Value : " + entry.getValue());
}

具有值 [] 的内容编码将被打印.

Content-Encoding with value [] will be printed.

这篇关于如何了解网站正在使用gzip压缩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆