Skip to content

build(dashboard): implement caching for dashboard downloads#60

Open
Cleboost wants to merge 6 commits into
temper-mc:devfrom
Cleboost:build/dahboard-cache
Open

build(dashboard): implement caching for dashboard downloads#60
Cleboost wants to merge 6 commits into
temper-mc:devfrom
Cleboost:build/dahboard-cache

Conversation

@Cleboost

@Cleboost Cleboost commented May 25, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the build process for the dashboard by introducing a caching mechanism to avoid unnecessary downloads. The build script now checks the age of the cached dashboard and only downloads a new copy if the cache is older than 24 hours or if explicitly forced by an environment variable. This should speed up builds and reduce redundant network usage.

Dashboard download caching:

  • Added logic to check the modification time of the cached index.html file and only download the dashboard if it is older than 24 hours.
  • Introduced the TEMPER_FORCE_DASHBOARD_DOWNLOAD environment variable to force a dashboard download regardless of cache age. [1] [2]
  • Added a message indicating when the cached dashboard is used and instructions to force an update.

Other improvements:

  • Changed warning messages to regular informational messages for dashboard download and extraction to reduce build noise.
  • Added std::time::SystemTime import to support cache age checking.
cargo run
warning: /home/cleboost/Code/temper/src/config/Cargo.toml: version requirement `1.1.2+spec-1.1.0` for dependency `toml` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
    Blocking waiting for file lock on artifact directory
   Compiling libc v0.2.186
   Compiling cfg-if v1.0.4
   Compiling pin-project-lite v0.2.17
	... (clear for size)
   Compiling memchr v2.8.0
   Compiling bin-runtime v0.1.0 (/home/cleboost/Code/temper/src/app/runtime)
   Compiling temper-app v0.1.1 (/home/cleboost/Code/temper/src/app)
   Compiling temper v0.1.1 (/home/cleboost/Code/temper/src/bin)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 22s
     Running `target/debug/temper`

touch src/dashboard/build.rs # Need touch for demo because cargo use his "replay" for console so we can't se cache (but it's been applied)

cargo run
warning: /home/cleboost/Code/temper/src/config/Cargo.toml: version requirement `1.1.2+spec-1.1.0` for dependency `toml` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
   Compiling temper-dashboard v0.1.0 (/home/cleboost/Code/temper/src/dashboard)
warning: temper-dashboard@0.1.0: Using cached Dashboard (last downloaded <24h ago). Set TEMPER_FORCE_DASHBOARD_DOWNLOAD=1 to force update.
   Compiling bin-runtime v0.1.0 (/home/cleboost/Code/temper/src/app/runtime)
   Compiling temper-app v0.1.1 (/home/cleboost/Code/temper/src/app)
   Compiling temper v0.1.1 (/home/cleboost/Code/temper/src/bin)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.42s
     Running `target/debug/temper`

fix #29

Comment thread src/dashboard/build.rs Outdated
for i in 0..archive.len() {
let mut file = archive.by_index(i)?;
let outpath = dest_dir.join(file.mangled_name()?);
let client = reqwest::blocking::Client::new();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a timeout please ?

Comment thread src/dashboard/build.rs Outdated
fs::remove_dir_all(&dest_dir)?;
}
// 2. Check cache age to avoid downloading on every single compile.
let force_download = env::var("TEMPER_FORCE_DASHBOARD_DOWNLOAD").is_ok();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you follow the convention and do something like that :

env::var("TEMPER_FORCE_DASHBOARD_DOWNLOAD").map(|v| v == "1").unwrap_or(false)

@Cleboost Cleboost requested a review from Tonguechaude May 27, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop downloading the dashboard on every compile

2 participants