Skip to content

Commit

Permalink
demo frontends: no caching callbacks in browser
Browse files Browse the repository at this point in the history
Disables the browser from caching our POST fetch requests.
  • Loading branch information
astraw committed Oct 31, 2023
1 parent bb17211 commit 379ccc7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions bui-demo/frontend_js/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function send_message(msg) {
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'callback');
httpRequest.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
httpRequest.setRequestHeader('Cache-Control', 'no-cache, no-store, max-age=0');
httpRequest.send(buf);
}

Expand Down
2 changes: 1 addition & 1 deletion bui-demo/frontend_seed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
seed = "0.10.0"
wasm-bindgen = "0.2.83"
wasm-bindgen-futures = "0.4"
web-sys = {version="0.3", features=["console", "EventSource", "MessageEvent"]}
web-sys = {version="0.3", features=["console", "EventSource", "MessageEvent", "RequestCache",]}
serde = "1.0.85"
serde_json = "1.0.39"
bui-demo-data = {path="../bui-demo-data"}
Expand Down
1 change: 1 addition & 0 deletions bui-demo/frontend_seed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async fn send_message(msg: Callback) -> Msg {
use web_sys::{Request, RequestInit, Response};
let mut opts = RequestInit::new();
opts.method("POST");
opts.cache(web_sys::RequestCache::NoStore);
let buf = serde_json::to_string(&msg).unwrap();
opts.body(Some(&JsValue::from_str(&buf)));

Expand Down
1 change: 1 addition & 0 deletions bui-demo/frontend_yew/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ features=[
"HtmlInputElement",
"MessageEvent",
"Request",
"RequestCache",
"RequestInit",
"RequestMode",
"Response",
Expand Down
1 change: 1 addition & 0 deletions bui-demo/frontend_yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ async fn post_callback(msg: Callback) -> Result<(), FetchError> {
use web_sys::{Request, RequestInit, Response};
let mut opts = RequestInit::new();
opts.method("POST");
opts.cache(web_sys::RequestCache::NoStore);
// opts.mode(web_sys::RequestMode::Cors);
// opts.headers("Content-Type", "application/json;charset=UTF-8")
// set SameOrigin
Expand Down

0 comments on commit 379ccc7

Please sign in to comment.