Optimised cach usage, and enforced maker checker

This commit is contained in:
2026-10-25 10:11:57 +02:00
parent 9724bbac24
commit aeb7542cfe
20 changed files with 277 additions and 428 deletions
@@ -39,6 +39,8 @@ export const apiClient = axios.create({
headers: {
'Content-Type': 'application/json; version=1',
Accept: 'application/json; version=1',
'Cache-Control': 'no-cache, no-store, must-revalidate',
Pragma: 'no-cache',
},
timeout: 15000,
});
@@ -58,31 +60,16 @@ apiClient.interceptors.request.use(
config.url?.includes('amazonaws.com') ||
config.url?.includes('garage');
// Always attach freshness timestamp and mutation epoch to internal GET requests
// to guarantee zero stale data, bypass browser HTTP caches, and prevent stale OutputCache hits
if (config.method?.toUpperCase() === 'GET' && !isExternal) {
const headers = config.headers || {};
const hasNoCacheHeader =
headers['Cache-Control'] === 'no-cache' ||
headers['cache-control'] === 'no-cache' ||
headers['Pragma'] === 'no-cache';
if (hasNoCacheHeader) {
if (config.params instanceof URLSearchParams) {
config.params.set('_t', String(Date.now()));
} else {
config.params = config.params || {};
config.params._t = Date.now();
}
if (config.params instanceof URLSearchParams) {
config.params.set('_t', String(Date.now()));
config.params.set('_v', String(getMutationEpoch()));
} else {
if (config.params instanceof URLSearchParams) {
if (!config.params.has('_v') && !config.params.has('_t')) {
config.params.set('_v', String(getMutationEpoch()));
}
} else {
config.params = config.params || {};
if (!config.params._v && !config.params._t) {
config.params._v = getMutationEpoch();
}
}
config.params = config.params || {};
config.params._t = Date.now();
config.params._v = getMutationEpoch();
}
}