Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ladjs/express-cachebuster
Provides cross-browser version-control/cache-busting as a dynamic view helper in express.
https://github.com/ladjs/express-cachebuster
Last synced: 2 days ago
JSON representation
Provides cross-browser version-control/cache-busting as a dynamic view helper in express.
- Host: GitHub
- URL: https://github.com/ladjs/express-cachebuster
- Owner: ladjs
- Archived: true
- Created: 2011-12-19T17:59:59.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T03:53:41.000Z (over 8 years ago)
- Last Synced: 2024-10-12T00:42:17.111Z (23 days ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Express Cachebuster
`express-cachebuster` provides cross-browser version-control/cache-busting as a dynamic view helper in `express`.
This was made as an integrated feature of [Expressling][1].
[1]: http://expressling.com# Quick install
$ npm install express-cachebuster
# Usage
Add the following to your `express` app, e.g., `server.js`:
app.configure(function() {
app.set('public', __dirname + '/public')
});app.dynamicHelpers({
cacheBuster: require('express-cachebuster')
});In your views execute the `cacheBuster` function and pass your asset's path.
For more options see Goodies.
**Note:** `$` = variable which is automagically returned by `express-cachebuster`.
## EJS
<%- cacheBuster('/js/mylibs/script.js') %>
Outputs HTML as shown below for development environment:
… and for production environment:
## Jade
!= cacheBuster('/stylesheets/style.css')
Outputs HTML as shown below for development environment:
… and for production environment:
# Goodies
### You can pass an array of assets to the middleware:
**EJS:** `<%- cacheBuster(['/stylesheets/style.css', '/stylesheets/ie.css']) %>`
**Jade:** `!= cacheBuster(['/stylesheets/style.css', '/stylesheets/ie.css'])`
Outputs HTML as shown below for development environment:
… and for production environment:
### You can pass an object as the second parameter representing attributes and their values to add to the generated tag:
cacheBuster('/scripts/require.js', {'data-message': 'Hello world', 'data-main': '/app/main.js'})
which outputs the following HTML:
# Contributors
David Murdoch - - [@davidmurdoch](https://github.com/davidmurdoch)
Butu - - [@butu5](https://github.com/butu5)# License
MIT Licensed