เว็บเซิร์ฟเวอร์และโฮสติ้ง

How to check that the Apache compression (gzip, deflate) is working?

apache web serverการตรวจสอบว่า apache ที่ได้ config ไปนั้นได้ทำการ compress data ก่อนส่งไปยัง client หรือไม่ ผ่านทาง command line ของระบบ สามารถทำได้โดยใช้คำสั่ง curl ในการตรวจสอบ วิธีการตรวจสอบ จะใช้วิธีการส่ง request ไปยัง apache ว่าบอกว่าให้สามารถส่งข้อมูลมาด้วยวิธีการ compression มาได้ และหลังจากนั้นให้เราตรวจสอบจาก header ที่ apache ได้ตอบกลับมา ว่ามีเป็นการส่งข้อมูลมาแบบไหน ตัวอย่างคำสั่งในการตรวจสอบว่า apache รองรับการทำงานแบบบีบอัดข้อมูลหรือไม่

[tum@ezylinux ~]$ curl -I -H 'Accept-Encoding: gzip,deflate' http://www.ezylinux.com |grep "Content-Encoding"

โดยแทน http://www.ezylinux.com เป็น URL ที่ต้องการตรวจสอบ ถ้าหากรองรับการทำงานแบบบีบอักข้อมูลจะตอบกลับมาดังนี้

[...]
Content-Encoding: gzip
[...]

หรือ

[...]
Content-Encoding: deflate
[...]

ตัวอย่างการรันคำสั่ง และ ผลลัพธ์

[tum@ezylinux ~]$ curl -I -H 'Accept-Encoding: gzip,deflate' http://www.ezylinux.com |grep "Content-Encoding"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  8202    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Content-Encoding: gzip
EOF.← กลับไปอ่านบทความอื่น