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:
parent
cd1237cfc6
commit
4a58996e44
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user