htmx icon indicating copy to clipboard operation
htmx copied to clipboard

getCacheBusterParam doesn't work as documented

Open lookbusy1344 opened this issue 11 months ago • 0 comments

Regarding htmx.config.getCacheBusterParam the documentation says

“defaults to false, if set to true htmx will include a cache-busting parameter in GET requests to avoid caching partial responses by the browser”

But the only effect of setting true seems to appending a static id to the request:

https://localhost:7203/?handler=MyHandler&org.htmx.cache-buster=myDiv

Digging in the source I found:

https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L3203

if (htmx.config.getCacheBusterParam && verb === 'get') {
   filteredParameters['org.htmx.cache-buster'] = getRawAttribute(target, "id") || "true";
}

Introduced entirely in 613f7b61d59e8ac4741e02d9f468ca635773ab2d (9 Jan 2023), its not been modified since.

The documented behaviour is what I’d like, but it seems different from what’s implemented.

Is this a bug? Is this a fix:

if (htmx.config.getCacheBusterParam && verb === 'get') {
   filteredParameters['org.htmx.cache-buster'] = new Date().getTime();
}

lookbusy1344 avatar Mar 02 '24 13:03 lookbusy1344