feat: Обновить логику кэширования для запросов GET, добавив исключение для /communities, чтобы всегда запрашивать свежие данные и улучшить обработку заголовков If-None-Match
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m56s

This commit is contained in:
2025-08-27 15:24:59 +07:00
parent 82fb2404a2
commit 9e16a0966f
+15 -5
View File
@@ -87,11 +87,21 @@ api.interceptors.request.use((config) => {
// If-None-Match для GET на базе кеша
const method = String(config.method || 'get').toLowerCase();
if (method === 'get') {
const key = buildCacheKey(config);
const cached = responseCache.get(key);
if (cached?.etag) {
config.headers = config.headers || {};
if (!config.headers['If-None-Match']) config.headers['If-None-Match'] = String(cached.etag);
// Исключение: для /communities всегда запрашиваем свежие данные (без условного GET)
const rawUrl = String(config.url || '');
const pathOnly = rawUrl.split('?')[0];
const isCommunities = pathOnly === '/communities' || pathOnly.endsWith('/communities');
if (!isCommunities) {
const key = buildCacheKey(config);
const cached = responseCache.get(key);
if (cached?.etag) {
config.headers = config.headers || {};
if (!config.headers['If-None-Match']) config.headers['If-None-Match'] = String(cached.etag);
}
} else if (config.headers && config.headers['If-None-Match']) {
// На всякий случай удалим, если был выставлен где-то ещё
delete config.headers['If-None-Match'];
}
}
// Если заголовок не указан, но в теле есть etag — пробуем проставить If-Match