Fix caching

Nginx's std cfg only returns 304 with If-Unmodified-Since header, if the date
is exactly the one it expects, not the date the client did its last request.

This makes sense as it is much easier to compare two strings for equality than
to parse the date received from the client and check the ordering with the
server known last_modified value.
This commit is contained in:
Thomas Koch 2025-01-11 13:38:20 +02:00
parent cd1237cfc6
commit 4a58996e44
2 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ use url::Url;
#[derive(Deserialize, Serialize, Default)]
pub struct FetchData {
pub etag: String,
pub date: String,
pub last_modified: String,
}
pub struct FeedStore {
@ -81,7 +81,7 @@ impl FeedStore {
let headers = response.headers();
let fetchdata = FetchData {
etag: hv(headers, "etag"),
date: hv(headers, "date"),
last_modified: hv(headers, "last_modified"),
};
let body = response

View File

@ -40,8 +40,8 @@ impl Fetcher {
if !fetchdata.etag.is_empty() {
builder = builder.header("If-None-Match", fetchdata.etag);
}
if !fetchdata.date.is_empty() {
builder = builder.header("If-Modified-Since", fetchdata.date);
if !fetchdata.last_modified.is_empty() {
builder = builder.header("If-Modified-Since", fetchdata.last_modified);
}
let start_instant = Instant::now();