[NOTE - This section needs to be tested since we migrated to using crates]
Cache busting is where we invalidate a cached file and force the browser to retrieve the file from the server. We can instruct the browser to bypass the cache by simply changing the filename. To the browser, this is a completely new resource so it will fetch the resource from the server. The most common way to do this is to add the hash of the file to the URL.
Let's turn our
asset-pipeline folder into a Rust crate. We do this because we can use
Run the following...
crates/asset-pipeline/build.rs so that the
main method looks like the following.
And add the following to
crates/asset-pipeline/Cargo.toml in the dependencies section.
# Used by ructe for image mime type detection
Ructe will now take our assets and turn them into rust functions. It handles creating a hash for the assets so we get good browser cache busting.
dbg!(index_css.name) -> index.234532455.css
crates/axum-server/main.rs create the following function.
And add the following route also in
And change the
use section so it looks like the following.