use ETag/Last-Modified only if URL hasn't changed

This commit is contained in:
Astro 2019-10-11 21:51:29 +02:00
parent e466c0a048
commit e1ef380b96
1 changed files with 8 additions and 1 deletions

View File

@ -104,7 +104,14 @@ impl Resources {
.filter(schema::calendars::dsl::id.eq(id.clone()))
.set(schema::calendars::dsl::last_fetch.eq(Utc::now().naive_utc()))
.execute(&db)?;
Ok((cal.etag.clone(), cal.last_modified.clone()))
let result =
// Use ETag/Last-Modified only if URL hasn't changed
if cal.url == cal_opts.url {
(cal.etag.clone(), cal.last_modified.clone())
} else {
(None, None)
};
Ok(result)
}
}
})?;