A cachebust="yes" attribute wouldn’t be useful in practice because the server would either be serving it to everyone, effectively disabling caching (and which would be better done by actually disabling caching with the cache-control header), or need to decide who to serve the attribute to, in which case there are better solutions. In short, cache busting only works if you have some sort of cache key, which is what the query string technique is all about doing.
<img src="/path/to/file.[last modified timestamp].png">
PHP code for this kind of thing might look like this: function auto_version($urlpath) {
// get a filesystem path
$fspath = $_SERVER['DOCUMENT_ROOT'] . $urlpath;
// if file doesn't exist, don't mess with the url
if (!file_exists($fspath)) {
return $urlpath;
}
// insert last modified timestamp
$mtime = filemtime($fspath);
return preg_replace('{\\.([^./]+)$}', ".$mtime.\$1", $urlpath);
}
Then in .htaccess or equivalent to strip the timestamp back off before serving the file: RewriteRule ^(.*)\.[\d]{10}\.(css|js|png)$ $1.$2 [L]
Whenever the file is updated you automatically start serving a new link which points to the same file, and otherwise you can rely on the browser caching. You don't need to mess around with ?params, which also helps semantically because those incorrectly suggest that the resource is dynamic. integrity="<hash>"
This would kill two birds with one stone: If it changes in HTML, this means:- Please bust cache
- Refetch and ensure, that the fetched file is securely valid
And it could be optional for every fetchable resource (img, video, css, js, etc.)
Possibly an app that did that sort of thing would be some kind of gallery or other very image-centric app.
And if that were the case, then I would think the image URLs would be dynamic, not burned into the deployment.