Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не кешируются запросы со статусом ответа 204 #397

Open
ItMaga opened this issue Mar 29, 2024 · 0 comments

Comments

@ItMaga
Copy link
Member

ItMaga commented Mar 29, 2024

Проблема

Cейчас в кеш сохраняется результат если выставлен флаг bodyUsed. Слушатель здесь

const saveAndClear = () => {
save();
// eslint-disable-next-line @typescript-eslint/no-use-before-define
emitter.off('bodyUsed', clear);
};
const clear = () => {
resolve(resObj);
emitter.off('bodyUsed', saveAndClear);
};
emitter.once('bodyUsed', saveAndClear);

Но для статусов "без контента" мы не выставляем флаг bodyUsed

if (noContentStatusCodes.includes(this.status)) {
data = null;
} else {

Решение

Одним из решений является помечать bodyUsed для статусов "без контента". Но надо посмотреть детальнее и проверить может ли что-то сломать

if (noContentStatusCodes.includes(this.status)) {
    data = this.readBody().then(() => null);
}
@ItMaga ItMaga changed the title Не кешируется запросы со статусом ответа 204 Не кешируются запросы со статусом ответа 204 Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant