When you perform an HTTP/HTTPS GET or POST methods to get a payload from the server, you can make a request for a compressed payload by passing in the --compressed option.
By doing so the response is provided to you via the network in a compressed form thus saving bandwidth, thus you receive the data quite quickly.Example 1 : Normal HTTP GET Request
% curl -o news.html "https://news.google.com/search?q=technology%20news&hl=en-US&gl=US&ceid=US%3Aen" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2686k 0 2686k 0 0 1652k 0 --:--:-- 0:00:01 --:--:-- 1654k
Now let's make this request efficient by using the --compressed option.
Example 2 : HTTP GET Request with --compressed option
% curl --compressed -o news.html.gz "https://news.google.com/search?q=technology%20news&hl=en-US&gl=US&ceid=US%3Aen" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 459k 0 459k 0 0 308k 0 --:--:-- 0:00:01 --:--:-- 309k
As you can see in the second example, the bytes received are 459k as compared to 2686k which is ~80% less.
Note: When the --compressed option is used, cURL requests the server to provide the data in the compressed form before sending it to you, and then cURL uncompresses it before displaying it to you to Standard Output. If the server does not support compression, you will get the data without compression as usual.
Facing issues? Have Questions? Post them here! I am happy to answer!
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- Capture cURL Request Output to a File
- Fix: Curl No Match Found Error
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- Send JSON Data as Payload using cURL HTTP POST Request
- cURL: Show Request and Response Headers
- Get cURL command from Chrome Inspect Network HTTP URL
- Save cURL Command Output to a external file
- cURL DELETE Request with Examples
- How to URL Encode Data for a cURL Request Parameters
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to convert a Postman request to cURL Command
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- How to follow redirects in cURL Command Request
- How to pass authorization header using cURL
- cURL -x Use of HTTP Proxy Server Examples
- Downloading Google Chrome using cURL Command
- How to get cURL Command to run in verbose mode?
- List of 28 Protocols supported by cURL with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL -d Option with Examples
- How to show SSL Certificate details using cURL Command
- Perform Basic Authentication using cURL with Examples
- How to format or prettify XML in Notepad++ - NotepadPlusPlus
- How to save All Files at once in Notepad++ - NotepadPlusPlus
- How to Copy full Absolute Path of a File on Mac - MacOS
- Fix: zipfile.BadZipFile: File is not a zip file Python - Python
- Python: Traverse List Backwards - Python
- How to Copy to Clipboard using Terminal Command - MacOS
- [Solution] Error: brew cask is no longer a brew command - MacOS
- [Program] How to read three different values using Scanner in Java - Java