playcanvas / playcanvas/engine
Allow cache-busting parameter to be disabled for asset loading
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Description
Asset files are loaded with a URL parameter (?t=...), added by the Asset.getFileUrl function. Here's the relevant code, from src/asset/asset.js:
getFileUrl() {
...
// add file hash to avoid hard-caching problems
if (this.type !== 'script' && file.hash) {
var separator = url.indexOf('?') !== -1 ? '&' : '?';
url += separator + 't=' + file.hash;
}
There doesn't appear to be any way to disable this. This can cause issues in a lot of configurations (CDNs, service workers, etc), and can make it very difficult to set up specific caching behaviors for production. It also produces a lot of noise in server/devtools logs.
It would be great if we could get a configuration option (maybe in __settings__.js?) to disable this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/asset/asset.js at Asset.getFileUrl and inspect how the proposed settings.js option could reach asset URL generation. Define the configuration behavior so cache-busting remains enabled by default and can be disabled, then verify that generated asset URLs omit the t parameter when disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100