https://github.com/stealjs/cache-bust
A cache busting extension for StealJS
https://github.com/stealjs/cache-bust
Last synced: 6 months ago
JSON representation
A cache busting extension for StealJS
- Host: GitHub
- URL: https://github.com/stealjs/cache-bust
- Owner: stealjs
- License: mit
- Created: 2015-04-01T02:12:58.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-10-22T05:18:02.000Z (about 6 years ago)
- Last Synced: 2025-04-24T06:17:26.559Z (8 months ago)
- Language: JavaScript
- Homepage: https://stealjs.com/docs/config.cacheVersion.html
- Size: 28.3 KB
- Stars: 6
- Watchers: 11
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# cache-bust
[](https://www.bitovi.com/community/slack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://forums.bitovi.com/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://github.com/stealjs/steal/blob/master/license.md)
[](http://badge.fury.io/js/steal-cache-bust)
[](https://travis-ci.org/stealjs/cache-bust)
[](https://greenkeeper.io/)
A StealJS and SystemJS cache busting extension.
> **Deprecated:** this package is now built into [steal](https://github.com/stealjs/steal/). See the [cacheVersion](https://stealjs.com/docs/config.cacheVersion.html) documentation for more details.
# Install
You can install through NPM:
```
npm install steal-cache-bust --save
```
You'll then want to copy `node_modules/steal-cache-bust/cache-bust.js` to a location within your project folder. In the future this extension will be included in Steal by default.
# Usage
With StealJS simply include cache-bust as a configDependency. Assuming you placed it in your root folder:
```json
{
"system": {
"configDependencies": [
"cache-bust"
]
}
}
```
If you prefer leaving cache-bust in your `node_modules` folder you should use the full path to the `cache-bust.js` file:
```json
{
"system": {
"configDependencies": [
"node_modules/steal-cache-bust/cache-bust.js"
]
}
}
```
# Configuration
When not running in production the `cacheVersion` is ignored and a timestamp is added instead. As some files do not pass through steal no cache busting can be applied to those. When developing using Chrome as your browser you may want to tick the 'Disable cache (while DevTools is open)' checkbox under *Settings | Preferences | Network* to prevent caching altogether while you are developing.
You can configure cache busting by setting properties on the script tag. You'll probably at least want to set `cacheVersion`.
## cacheVersion
This is the version string that will be appending as a query parameter inwhen running in **production.** For example if you do:
```html
```
Then requests will be for:
```
http://example.com/foo/bar.js?version=14
```
This version should be changed for each production release to ensure that the latest code is retrieved from the server.
If you do not specify a `cacheVersion` value a timestamp will be added as the cache busting parameter. This is not ideal for a production environment as you will lose all the benefits of browser caching.
## cacheKey
By default **"version"** is used as the query param for busting caches but you can use a different string by setting `cacheKey`.
## License
MIT