Crates.io | libcachebust |
lib.rs | libcachebust |
version | 0.3.0 |
source | src |
created_at | 2023-10-16 18:07:25.334264 |
updated_at | 2023-10-16 18:53:24.878318 |
description | Compiletime cache-busting web applications written in rust |
homepage | https://git.batsense.net/realaravinth/libcachebust |
repository | https://git.batsense.net/realaravinth/libcachebust |
max_upload_size | |
id | 1004968 |
size | 138,328 |
To optimise network load time, browsers cache static files. Caching greatly improves performance but how do you inform browsers to invalidate cache when your files have changed?
Cache busting is a simple but effective solution for this issue. There are several ways to achieve this but the way this library does this is by changing file names to include the hash of the files' contents.
So if you have bundle.js
, it will become
bundle.<long-sha256-hash>.js
. This lets you set a super long cache age
as, because of the file names changing, the path to the filename, too,
will change. So as far as the browser is concerned, you are trying to load
a file that it doesn't have. Pretty neat, isn't it?
SHA-256
based name generation during compile-timeAdd this to your Cargo.toml
:
libcachebust = 0.2