Revalidate A Cached Copy
A page or file comes with an ETag header. Keep it with the body you store, and send it back to find out whether the page changed.
Check A Page
Save the ETag exactly as received, with its quotes and any W/ prefix. Send it in If-None-Match on the next GET.
curl -si "$SITE/" -H 'If-None-Match: "SAVED_ETAG"'
- HTTP 304 means your stored body is still current.
- HTTP 200 carries a new body and a new
ETag. Store both.
Use HEAD when you need only the headers.
Resume A Download
A binary response includes Accept-Ranges: bytes and a strong ETag. To resume, send one byte range and the saved tag in If-Range.
curl -s "$SITE/press/cover.pdf" -H 'Range: bytes=1048576-' -H 'If-Range: "SAVED_ETAG"' -o rest.part
A matching tag returns HTTP 206 with the rest of the file. A changed tag returns the whole new file.
To fail instead when the file has changed, send the tag in If-Match with the Range. If a publish or rollback changed the bytes at that path, FOLD returns 412 Precondition Failed with an empty body.
Choose Which Path To Store
A file has two paths. The authored path, such as /press/cover.pdf, follows the site: after a publish or rollback it serves the live release's bytes. The path under /_fold/media/ includes the file's hash, never changes, and can be cached for a year.
Next: Submit a form