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!
- Get cURL command from Chrome Inspect Network HTTP URL
- Downloading Google Chrome using cURL Command
- Get the Size of HTTP Response using cURL Command (Content Length)
- How to set Connection and Max Timeout for cURL Request with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL Example using IP (IPv4 and IPv6) address and Port
- Perform Basic Authentication using cURL with Examples
- Efficient way to perform HTTP cURL GET/POST Requests with Payload
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- Trace using cURL Command Example
- Fetch only content-type using cURL Command
- cURL Option to show HTTP Response Status Code
- [fix] command not found curl
- How to get cURL Command to run in verbose mode?
- Save cURL Command Output to a external file
- List of 28 Protocols supported by cURL with Examples
- URL Encode cURL HTTP GET\POST Data with Examples
- How to Pretty Print cURL JSON Output in Terminal
- [fix] Microsoft Error Code 0x80004005 - Unspecified error - Microsoft
- How to change default browser on Mac Monterey - MacOS
- Create Symbolic Link using Terminal Command - MacOS
- Fibonacci series from 1 to 500 table - Html
- Unable to find image docker latest locally - Docker
- Spring Boot: Setting up JDBCTemplate with MySQL Tutorial - Java
- Health Status Page for OpenAI ChatGPT or GPT 4 - HowTos
- SharePoint Online REST API not returning all list items and limit to only 100 rows - SharePoint