Skip to content

Instantly share code, notes, and snippets.

@cb109
Created March 6, 2026 12:14
Show Gist options
  • Select an option

  • Save cb109/3535b87eb616493ae3c8925fd80fc92c to your computer and use it in GitHub Desktop.

Select an option

Save cb109/3535b87eb616493ae3c8925fd80fc92c to your computer and use it in GitHub Desktop.
chrome extension to auto-increment cache busting query parameter in url
/**
* Installation: chrome://extensions -> Load unpacked -> select folder
* Bind Ctrl+Shift+R as a shortcut for "cachebust-refresh" in chrome://extensions/shortcuts
*/
function bust(tab) {
if (!tab.url) return;
const url = new URL(tab.url);
const param = "_cacheBust";
const current = url.searchParams.get(param);
if (current === null) {
url.searchParams.set(param, "1");
} else {
const next = parseInt(current, 10) + 1;
url.searchParams.set(param, String(next));
}
chrome.tabs.update(tab.id, { url: url.toString() });
}
chrome.action.onClicked.addListener(bust);
chrome.commands.onCommand.addListener(async (command) => {
if (command === "cachebust-refresh") {
const [tab] = await chrome.tabs.query({
active: true,
currentWindow: true,
});
if (tab) bust(tab);
}
});
{
"manifest_version": 3,
"name": "CacheBust Incrementer",
"version": "1.1",
"description": "Increment ?_cacheBust on the current URL.",
"permissions": ["tabs"],
"action": {
"default_title": "Increment CacheBust"
},
"background": {
"service_worker": "background.js"
},
"commands": {
"cachebust-refresh": {
"suggested_key": {
"default": "Ctrl+Shift+R"
},
"description": "Increment _cacheBust and reload"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment