UNPKG

gulp-ui5-cachebuster

Version:

Create a cachebuster folder and json for SAPUI5 / OpenUI5.

46 lines (30 loc) 1.45 kB
# gulp-ui5-cachebuster Needed something that created the cache buster file and directories for me. I'll expand on this sometime to make a fancier one. For now, this'll do. ## Info: By default, Browsers cache files. Why fetch something when you already have it? Usually this is great and it'll speed up your application. Sometimes you make changes though and your customers should fetch a fresh copy from the server instead of using their locally cached one. The process of enabling such a refresh is known as a cache buster. In short, the way UI5 implements it, is by providing a file called `sap-ui-cachebuster-info.json` which contains the files and cache buster folder, something like this: ``` { "my/app/App.controller.js": "1495521267770" } ``` I implement these on a time stamp but you have the freedom to change this. ## Basic usage Part of my gulp file: ``` const cachebuster = require('gulp-ui5-cachebuster'); const APP = './'; const DIST = `${APP}/dist`; const SRC = `${APP}/src`; const TIME = new Date().getTime(); //ie, 1495521267770 gulp.task("copy:cachebuster", () => { return gulp.src([ `${DIST}/**/*` ]) .pipe(gulp.dest(`${APP}/~${TIME}~/dist`)) .pipe(cachebuster(TIME, 'dist')) }); ``` Copies my source folders to a folder called "~1495521267770~" and generates the json file. ## More info Read more over [here](https://openui5.hana.ondemand.com/#docs/guide/ff7aceda0bd24039beb9bca8e882825d.html)