Skip to content

Commit

Permalink
fix: [#2535] Update to default false on cache busting (#2663)
Browse files Browse the repository at this point in the history
Closes #2535

This PR updates `bustCache= false` by default and provides a `bustCache` property on all built in `Resource` implementations.
  • Loading branch information
eonarheim authored Jun 15, 2023
1 parent 0d5a41f commit e210513
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ stored `ex.Graphics` causing them to be shared across clones.

### Changed

-
- Excalibur resources by default no longer add cache busting query string to resources. All built in resources now expose a `bustCache` property to allow setting this before loading, for example `ex.Sound.bustCache`.



Expand Down
12 changes: 12 additions & 0 deletions src/engine/Graphics/ImageSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ export class ImageSource implements Loadable<HTMLImageElement> {
}
}

/**
* Should excalibur add a cache busting querystring? By default false.
* Must be set before loading
*/
public get bustCache() {
return this._resource.bustCache;
}

public set bustCache(val: boolean) {
this._resource.bustCache = val;
}

/**
* Begins loading the image and returns a promise that resolves when the image is loaded
*/
Expand Down
14 changes: 13 additions & 1 deletion src/engine/Resources/Gif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@ export class Gif implements Loadable<ImageSource[]> {
* @param color Optionally set the color to treat as transparent the gif, by default [[Color.Magenta]]
* @param bustCache Optionally load texture with cache busting
*/
constructor(public path: string, public color: Color = Color.Magenta, public bustCache = true) {
constructor(public path: string, public color: Color = Color.Magenta, bustCache = false) {
this._resource = new Resource(path, 'arraybuffer', bustCache);
this._transparentColor = color;
}

/**
* Should excalibur add a cache busting querystring? By default false.
* Must be set before loading
*/
public get bustCache() {
return this._resource.bustCache;
}

public set bustCache(val: boolean) {
this._resource.bustCache = val;
}

/**
* Begins loading the texture and returns a promise to be resolved on completion
*/
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Resources/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Resource<T> implements Loadable<T> {
constructor(
public path: string,
public responseType: '' | 'arraybuffer' | 'blob' | 'document' | 'json' | 'text',
public bustCache: boolean = true
public bustCache: boolean = false
) {}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/engine/Resources/Sound/Sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ export class Sound extends Class implements Audio, Loadable<AudioBuffer> {
this._resource.path = val;
}


/**
* Should excalibur add a cache busting querystring? By default false.
* Must be set before loading
*/
public get bustCache() {
return this._resource.bustCache;
}

public set bustCache(val: boolean) {
this._resource.bustCache = val;
}

private _loop = false;
private _volume = 1;
private _isStopped = false;
Expand Down

0 comments on commit e210513

Please sign in to comment.