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.
Have Questions? Post them here!
- How to set Connection and Max Timeout for cURL Request with Examples
- cURL Option to show HTTP Response Status Code
- [fix] command not found curl
- Perform Basic Authentication using cURL with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL Example using IP (IPv4 and IPv6) address and Port
- List of 28 Protocols supported by cURL with Examples
- Save cURL Command Output to a external file
- Get cURL command from Chrome Inspect Network HTTP URL
- URL Encode cURL HTTP GET\POST Data with Examples
- Efficient way to perform HTTP cURL GET/POST Requests with Payload
- Trace using cURL Command Example
- Get the Size of HTTP Response using cURL Command (Content Length)
- Fetch only content-type using cURL Command
- How to get cURL Command to run in verbose mode?
- Install Docker for Mac using Home-brew Cask - Docker
- How to Right Click on Mac Desktop? - MacOS
- Command to Sort File In Reverse Order [Unix/Linux/macOS] - Bash
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException - Android
- INVALID FILE NAME: MUST CONTAIN ONLY [a-z0-9_.] Android Eclipse Error - Eclipse
- [macOS] Change homepage Macbook Safari Browser - MacOS
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash] - Linux
- Google Search Hot Trends Screensaver for Mac OS X - MacOS