# cache-buster
[![crates.io](https://img.shields.io/crates/v/cache-buster.svg)](https://crates.io/crates/cache-buster)
`cache-buster` helps busting stale cache for static websites.
For instance, let's suppose you have the following structure, maybe generated by some other tool such as Jekyll:
```
.
├── assets
│ ├── scripts
│ │ └── main.js
│ └── style
│ └── main.css
└── index.html
```
And your index page is as beautiful as
```html
My Website
Hello, this is my gorgeous website.
```
`cache-buster` can update your HTML to update all assets with an hash of its contents:
```
$ cache-buster --assets assets --base-url https://my.website
```
Which will update your website to the following structure:
```
.
├── assets
│ ├── scripts
│ │ └── main_88782689275158862f158fb9030e2a2599bd82bb.js
│ └── style
│ └── main_1ae3e9bf3a50ebd227b33460915a7672e1f94382.css
└── index.html
```
and also update all your HTML files to point to the correct hashed files:
```html
My Website
Hello, this is my gorgeous website.
```
## Installing
Install using [`cargo`](https://crates.io/):
```
cargo install cache-buster
```
## Usage
```bash
# cd to your website output
▲ cd my-website
# and execute cache-buster
▲ cache-buster --assets assets --base-url my.website
# That's it!
```
### Supported Tags
Currently, `cache-buster` acts on all ``, ``, and `` tags.
## TODO
- [ ] Add Tests
- [ ] Add support to process CSS files
## License
```
MIT License
Copyright (c) 2021 Victor Gama
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```