# Problems getting Stealjs cache-bust to work

**URL:** https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514
**Category:** StealJS
**Created:** [December 22, 2016, 1:36pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514 "2016-12-22T13:36:12Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)
#### Post date: [December 22, 2016, 1:36pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/1 "2016-12-22T13:36:12Z")

</div>

Hello,

I am having trouble getting the stealjs cache-bust extension to work in production.

I have the following line in my index.html

`<script bundles-path="dist/bundles" src="/node_modules/steal/steal.production.js" data-main="app/app" cache-version="1"></script>`

I see the following when the resources are loaded in the browser…

```
  steal.production.js
  app.js
  app.css?version=1

```

I was expecting to see “?version=1” appended to the app.js resource too.

In the development version it all works as expected. I see the timestamp appended to all the resources.

Here is an extract from my package.js:

```
  "dependencies": {
    ...
    "can": "2.3.27",
    ...
    "steal": "0.15.5",
    "steal-cache-bust": "0.2.1",
    "steal-css": "0.4.1",
  },
  "system": {
    "configDependencies": [
      "node_modules/steal-cache-bust/cache-bust"
    ],
  }

```

Any help or pointers to a solution will be much appreciated!

Rob

---

<div class="post-metadata">

### Author: ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)
#### Post date: [December 22, 2016, 2:19pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/2 "2016-12-22T14:19:14Z")

</div>

is it necessary to use steal 0.15 ?  
can u use 0.16?

---

<div class="post-metadata">

### Author: ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)
#### Post date: [December 22, 2016, 2:45pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/3 "2016-12-22T14:45:51Z")

</div>

Thanks pYr0x  
I just updated to steal 0.16.43 and I still see the same thing.

---

<div class="post-metadata">

### Author: ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)
#### Post date: [December 22, 2016, 3:19pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/4 "2016-12-22T15:19:30Z")

</div>

hello @robfoweraker  
i have looked into this.

of course it is a design failure.

steal-cache-bust is working on development because steal knows that this is a config dependency. it loads steal-cache-bust before the index.js is loaded.  
in production steal-cache-bust is bundled into the index.js file and steal therefore cant be load the index.js file with the cache-bust extension because it dont know that cache-busting is enabled.

for any future files, steal will load these files with a version number

@matthewp  
my thoughts:  
either we integrate steal-cache-buster into core and enable it by setting the `steal` config  
or  
we add (in steal 1.0) the fetch hook into the steal.production.js that we copied into the dist folder and remove cache-buster from being bundled

---

<div class="post-metadata">

### Author: ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)
#### Post date: [December 22, 2016, 3:34pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/5 "2016-12-22T15:34:33Z")

</div>

Thanks again @pYr0x

Should I raise an issue somewhere?

---

<div class="post-metadata">

### Author: ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)
#### Post date: [December 22, 2016, 3:36pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/6 "2016-12-22T15:36:41Z")

</div>

i did

[https://github.com/stealjs/cache-bust/issues/12](https://github.com/stealjs/cache-bust/issues/12)

you can workaround by use `stealBundle=true` while building and use the bundled steal version.  
or you can add in the steal.production.js at the end following:

```auto
function _SYSTEM_addCACHE(loader) {

	var fetch = loader.fetch;
	var timestamp = new Date().getTime();
	var isBuildEnvironment = loader.isPlatform ? loader.isPlatform('build') || loader.isEnv('build') : typeof window === 'undefined';
	loader.fetch = function (load) {
		var loader = this;
		var cacheVersion;
		var cacheKey;
		var cacheKeyVersion;
		if (!isBuildEnvironment) {
			cacheVersion = isProduction() ? loader.cacheVersion || timestamp : timestamp;
			cacheKey = loader.cacheKey || 'version';
			cacheKeyVersion = cacheKey + '=' + cacheVersion;
			load.address = load.address + (load.address.indexOf('?') === -1 ? '?' : '&') + cacheKeyVersion;
		}
		return fetch.call(this, load);
	};
	function isProduction() {
		return loader.isEnv && loader.isEnv('production') || loader.env === 'production';
	}
}
if (typeof System !== "undefined") {
	_SYSTEM_addCACHE(System);
}

```

---

<div class="post-metadata">

### Author: ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)
#### Post date: [December 22, 2016, 3:43pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/7 "2016-12-22T15:43:59Z")

</div>

Thanks again. I will give it a go

---

<div class="post-metadata">

### Author: ![tai101568](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/tai101568/32/215_2.png) [@tai101568](https://forums.bitovi.com/u/tai101568)
#### Post date: [December 28, 2016, 10:01am UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/8 "2016-12-28T10:01:54Z")

</div>

Thanks pYr0x,

but steal.production.js be got from npm or bower, why do we to edit at this file?

---

<div class="post-metadata">

### Author: ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)
#### Post date: [December 28, 2016, 10:04am UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/9 "2016-12-28T10:04:42Z")

</div>

why do you have to edit this file?  
because if you did not, the cache buster plugin didn’t work. but you dont have to modifiy your steal at all, see below…

but you can also workaround by adding the cache buster file after steal… see matthew’s comment  
[https://github.com/stealjs/cache-bust/issues/12#issuecomment-269327725](https://github.com/stealjs/cache-bust/issues/12#issuecomment-269327725)

---

<div class="post-metadata">

### Author: ![tai101568](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/tai101568/32/215_2.png) [@tai101568](https://forums.bitovi.com/u/tai101568)
#### Post date: [December 29, 2016, 2:36am UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/10 "2016-12-29T02:36:05Z")

</div>

thanks pYr0x so much

---

<div class="post-metadata">

### Author: ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)
#### Post date: [February 7, 2017, 10:26am UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/11 "2017-02-07T10:26:59Z")

</div>

Any updates on this?  
I add steal.production.js and cach-bust.min.js like this on my page.

```auto
<script type="text/javascript" 
    base-url="/modules/myApp/dist" 
    cache-key="rev" 
    cache-version="f8408c55e4ce2e9e0fda" 
    src="/modules/myApp/dist/steal.production.rev-8fb596be55.js"></script>
<script type="text/javascript" 
    src="/modules/myApp/steal-cache-bust/cache-bust.min.rev-0bca36988f.js"></script>

```

Steal then loads main.js and main.js loads main.css.  
But only main.css is loaded with the cache-key/version. (main.css?rev=f840…)

---

<div class="post-metadata">

### Author: ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)
#### Post date: [February 7, 2017, 10:46am UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/12 "2017-02-07T10:46:09Z")

</div>

we released a new steal version 1.2.0 pre.2  
the cachebust is now a core module  
check out docs  
[https://github.com/stealjs/steal/pull/1045/files](https://github.com/stealjs/steal/pull/1045/files)

---

<div class="post-metadata">

### Author: ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)
#### Post date: [February 7, 2017, 1:26pm UTC](https://forums.bitovi.com/t/problems-getting-stealjs-cache-bust-to-work/514/13 "2017-02-07T13:26:44Z")

</div>

👍 Steal 1.2.0 solves this issue!  
Great work guys!

> **[stealjs/steal](https://github.com/stealjs/steal/releases/tag/v1.2.0)**
>
> Gets JavaScript. Contribute to stealjs/steal development by creating an account on GitHub.
