How does If-Modified-Since work?

Hi!

Following the examples of conditional requests, I try to make such a request using If-Modified-Since. But I simply cannot make it return 304, it always returns 200.
Using If-None-Match and ETag works and it returns 304.

Here’s the command line I test with:

curl -i https://codeload.github.com/JCash/jctest/zip/v0.6 -H “If-Modified-Since: Sat, 24 Oct 2020 08:00:00 GMT”

and the output:

HTTP/1.1 200 OK
Date: Sat, 24 Oct 2020 09:42:41 GMT
Content-Type: application/zip
Transfer-Encoding: chunked
Access-Control-Allow-Origin: https://render.githubusercontent.com
Content-Disposition: attachment; filename=jctest-0.6.zip
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
ETag: "983c54fcff8f1c3ba0215c38de3c3516c870b5cc25a62d6b793fc374098df1b0"
Strict-Transport-Security: max-age=31536000
Vary: Authorization,Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Varnish: 271244706
Age: 0
Via: 1.1 varnish (Varnish/6.0)
X-Cache: MISS
X-Cache-Hits: 0
Accept-Ranges: bytes
Vary: Accept-Encoding
X-GitHub-Request-Id: F07D:1211:B620AE:F008B3:5F93F711

Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: <FILE>" to save to a file.

Any hints would be appreciated!
Thanks!

/Mathias

IMS only functions if the response would have included a Last-Modified header; If-None-Match and Etag are similarly paired.

1 Like

Thanks!
I think what you say makes sense. It’s strange though that I haven’t seen it as a requirement in the documentation.

I think this would be a good improvement on Github’s part though, to add the Last-Modified header to all their assets.