How to use curl to compare the size of the page with deflate enabled and without using it

I think the only reliable way to get the size, is to actually download the file. However, curl offers a very convenient option for only outputting data of interest

-w/--write-out <format>
    Defines what to display on stdout after a completed and successful operation.

[...]

size_download  The total amount of bytes that were downloaded.

which means you can do something like this:

curl -so /dev/null http://www.whatsmyip.org/http-compression-test/ -w '%{size_download}'

Output:

8437

And to get the compressed size:

curl --compressed -so /dev/null http://www.whatsmyip.org/http-compression-test/ -w '%{size_download}'

Output:

3225

After that your comparison should be trivial.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)