Open
Description
Right now, HTML pages on docs.rs get no caching headers at all:
$ curl -iL docs.rs/regex | less
...
HTTP/2 200
content-type: text/html; charset=utf-8
content-length: 136585
server: nginx/1.14.0 (Ubuntu)
date: Fri, 26 Nov 2021 19:34:01 GMT
vary: Accept-Encoding
x-cache: Miss from cloudfront
via: 1.1 eece508272520f70691e4eebdc5a6dea.cloudfront.net (CloudFront)
x-amz-cf-pop: HIO50-C1
x-amz-cf-id: sDMQ3tIHBbZPLMSUynsQRoBTkxdeWH6pc_QqwGzxHSvGQe71aaccEw==
That's in part because they could be updated at any time. However, there's no need for the user's browser to load the whole thing every time. If we set Last-Modified and/or ETag, the browser can send a request with the If-None-Match and/or If-Modified-Since headers. In the common case when the document hasn't been updated, the server can reply with 304 and the browser will use what it has stored locally, saving a lot of bytes downloaded.
Note that doc.rust-lang.org already serves both ETag and Last-Modified, thanks to S3:
$ curl -i https://doc.rust-lang.org/nightly/std/string/struct.String.html | less
HTTP/2 200
content-type: text/html
content-length: 614892
date: Fri, 26 Nov 2021 19:58:13 GMT
last-modified: Fri, 26 Nov 2021 00:50:39 GMT
x-amz-version-id: 5q36d4E6SPVJsJeZ4l4N32_CxCLiRRwj
etag: "0a1f4a4cb8c158e2a3e92972a5c86673"
server: AmazonS3
vary: Accept-Encoding
x-cache: Miss from cloudfront
via: 1.1 87cff53a3b3c669d865b820d148e2d63.cloudfront.net (CloudFront)
x-amz-cf-pop: HIO50-C2
x-amz-cf-id: ThqtuTVHKIHpQxwJNpkzEuDXD4pFvshCbivyVGE55y2t9sp9mIyqkQ==