如何理解一个网站正在使用 gzip 压缩?
How to understand a website is using gzip compression?
我正在尝试检查是否有任何网站正在使用 gzip?
我在 Nibbler 上找到了这个解释,
We check if pages use GZIP compression for smaller page sizes and
faster downloading
html 中是否有任何内容表明使用了 gzip?我怎么理解?
打开chrome开发者工具
转到 "Network" 选项卡并重新加载页面。
在左边选择合适的page/file
然后是右窗格中的 "Headers" 选项卡。
在 "Response Headers" 下你应该看到 "Content-Encoding: gzip"
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());
}
将打印值为 []
的内容编码。
我正在尝试检查是否有任何网站正在使用 gzip?
我在 Nibbler 上找到了这个解释,
We check if pages use GZIP compression for smaller page sizes and faster downloading
html 中是否有任何内容表明使用了 gzip?我怎么理解?
打开chrome开发者工具
转到 "Network" 选项卡并重新加载页面。
在左边选择合适的page/file
然后是右窗格中的 "Headers" 选项卡。
在 "Response Headers" 下你应该看到 "Content-Encoding: gzip"
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());
}
将打印值为 []
的内容编码。