diff --git a/buffit/index.html b/buffit/index.html
index 693d935..da3038c 100644
--- a/buffit/index.html
+++ b/buffit/index.html
@@ -1076,7 +1076,7 @@
refreshBtn.textContent = 'Refreshing…';
try {
- const res = await fetch(PROXY_BASE + '/channels', {
+ const res = await fetch(PROXY_BASE + '/channels?nocache=1', {
method: 'GET',
headers: { 'Authorization': 'Bearer ' + tokens.access_token },
});
@@ -1089,7 +1089,7 @@
allChannels = data.channels || [];
selectedChannelIds.clear();
renderChannels(allChannels);
- setStatus(composerStatus, 'Channels refreshed.', 'success');
+ setStatus(composerStatus, 'Channels refreshed and cache cleared.', 'success');
setTimeout(() => setStatus(composerStatus, '', null), 2000);
} catch (e) {
setStatus(composerStatus, 'Failed to refresh: ' + e.message, 'error');
diff --git a/buffit/worker.js b/buffit/worker.js
index aeb825b..4808a08 100644
--- a/buffit/worker.js
+++ b/buffit/worker.js
@@ -94,18 +94,21 @@ export default {
return json({ success: false, error: 'Channels cache not configured' }, 500, cors);
}
+ const nocache = url.searchParams.get('nocache') === '1';
const cacheKey = await hashToken(authHeader);
- const cached = await env.CHANNELS_KV.get(cacheKey, { type: 'json' });
- if (cached) {
- return json(cached, 200, { ...cors, 'X-Cache': 'hit' });
+ if (!nocache) {
+ const cached = await env.CHANNELS_KV.get(cacheKey, { type: 'json' });
+ if (cached) {
+ return json(cached, 200, { ...cors, 'X-Cache': 'hit' });
+ }
}
try {
const channels = await fetchChannelsFromBuffer(authHeader);
const ttl = parseInt(env.CHANNELS_CACHE_TTL || '3600');
await env.CHANNELS_KV.put(cacheKey, JSON.stringify(channels), { expirationTtl: ttl });
- return json(channels, 200, { ...cors, 'X-Cache': 'miss' });
+ return json(channels, 200, { ...cors, 'X-Cache': nocache ? 'clear' : 'miss' });
} catch (e) {
return json({ success: false, error: `Failed to fetch channels: ${e.message}` }, 500, cors);
}