Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | curl |
Time | N/A |
Step #1: Find out if response has a Last-Modified header
Type the following curl command:
curl --silent --head http://server1.cyberciti.biz/foo/bar/image.png curl --silent --head http://server1.cyberciti.biz/foo/help.html
OR
curl -I http://server1.cyberciti.biz/foo/bar/image.png curl -I http://server1.cyberciti.biz/foo/help.html
In this example, note down the Last-Modified headers in the response to this HEAD request:
$ curl -I http://www.cyberciti.biz/faq/
Sample outputs:
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 11 Dec 2012 10:10:24 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Whom: l2-com-cyber
Last-Modified: Tue, 11 Dec 2012 10:10:23 GMT
Cache-Control: max-age=299, must-revalidate
Vary: Cookie
X-Pingback: http://www.cyberciti.biz/faq/xmlrpc.php
X-Galaxy: Andromeda-1
Vary: Accept-Encoding
The syntax is as follows to send If-Modified-Since header using the curl command line:
$ curl -I --header 'If-Modified-Since: DATE-FORMAT-HERE' http://server1.cyberciti.biz/foo/bar/image.png
$ curl -I --header 'If-Modified-Since: Tue, 11 Dec 2012 10:10:24 GMT' http://www.cyberciti.biz/faq/
Sample outputs:
HTTP/1.1 304 Not Modified
Server: nginx
Date: Tue, 11 Dec 2012 10:12:11 GMT
Connection: keep-alive
X-Whom: l2-com-cyber
Vary: Cookie
Last-Modified: Tue, 11 Dec 2012 10:10:23 GMT
X-Galaxy: Andromeda-1
Vary: Accept-Encoding
The resource sends a 304 Not Modified response, indicating that it supports Last-Modified validation.
🐧 2 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
How can you substitute the date part with a shell variable .. like this –
curl –silent -I –header ‘If-Modified-Since: “$mod”‘
Thanks
Isn’t this handled by --remote-time and --time-conf FILE ?