playcanvas / playcanvas/engine

Allow cache-busting parameter to be disabled for asset loading

Open
#3,392 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: assets enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.