Remove HTTP cache.

This commit is contained in:
Leonora Tindall 2022-12-05 09:48:17 -06:00
parent c8f236b6c0
commit b99aa07d88
3 changed files with 6 additions and 41 deletions

View File

@ -4,9 +4,7 @@ use std::error::Error;
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
use cached::proc_macro::cached; use cached::proc_macro::cached;
use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache}; use reqwest::{Client, StatusCode};
use reqwest::StatusCode;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use rocket::response::content::RawHtml; use rocket::response::content::RawHtml;
use rocket::serde::json::Json; use rocket::serde::json::Json;
@ -43,19 +41,11 @@ fn user_agent() -> String {
} }
static ARGS: once_cell::sync::Lazy<Args> = once_cell::sync::Lazy::new(|| Args::parse()); static ARGS: once_cell::sync::Lazy<Args> = once_cell::sync::Lazy::new(|| Args::parse());
static CLIENT: once_cell::sync::Lazy<ClientWithMiddleware> = once_cell::sync::Lazy::new(|| { static CLIENT: once_cell::sync::Lazy<Client> = once_cell::sync::Lazy::new(|| {
ClientBuilder::new( reqwest::Client::builder()
reqwest::Client::builder() .user_agent(user_agent())
.user_agent(user_agent()) .build()
.build() .unwrap()
.unwrap(),
)
.with(Cache(HttpCache {
mode: CacheMode::Default,
manager: CACacheManager::default(),
options: None,
}))
.build()
}); });
#[get("/")] #[get("/")]

View File

@ -1,23 +1,8 @@
use crate::cohost_account::CohostAccount; use crate::cohost_account::CohostAccount;
use crate::cohost_posts::*; use crate::cohost_posts::*;
use crate::ARGS; use crate::ARGS;
use atom_syndication::LinkBuilder;
use rss::extension::atom::{AtomExtensionBuilder, Link};
use rss::Channel; use rss::Channel;
fn rel_link_for(rel: &str, project_name: &str, page_number: u64) -> Link {
LinkBuilder::default()
.rel(rel)
.href(format!(
"https://{}{}{}/feed.rss?page={}",
&ARGS.domain,
&ARGS.base_url,
project_name.clone(),
page_number
))
.build()
}
pub fn channel_for_posts_page( pub fn channel_for_posts_page(
project_name: impl AsRef<str>, project_name: impl AsRef<str>,
project: CohostAccount, project: CohostAccount,
@ -40,15 +25,6 @@ pub fn channel_for_posts_page(
))) )))
.link(format!("https://cohost.org/{}", project_name,)); .link(format!("https://cohost.org/{}", project_name,));
let mut atom = AtomExtensionBuilder::default();
let links = vec![
rel_link_for("self", project_name, 0),
rel_link_for("first", project_name, 0),
];
atom.links(links);
builder.atom_ext(Some(atom.build()));
page.items.sort_by_key(|item| item.published_at); page.items.sort_by_key(|item| item.published_at);
let mut items = Vec::with_capacity(page.number_items); let mut items = Vec::with_capacity(page.number_items);
for item in page.items { for item in page.items {

View File

@ -77,7 +77,6 @@
<li>Project/account data for <b>60 seconds</b></li> <li>Project/account data for <b>60 seconds</b></li>
<li>Individual posts for <b>60 seconds</b></li> <li>Individual posts for <b>60 seconds</b></li>
<li>Whole RSS feeds for <b>120 seconds</b></li> <li>Whole RSS feeds for <b>120 seconds</b></li>
<li>Internal HTTP responses <b>according to Cohost's settings</b></li>
</ul> </ul>
This means that if you update a post and then immediately request its source, you might get the old source. Just wait a few seconds. This means that if you update a post and then immediately request its source, you might get the old source. Just wait a few seconds.
</p> </p>