fix(textbooks): html учебника всегда no-store (не кэшировать)
Раньше no-store ставился только в dev; в prod html главы кэшировался браузером/прокси и показывал устаревшую версию страницы (с пустыми builders → заглушки «Содержание готовится»). Теперь /textbook/:slug всегда отдаётся с Cache-Control: no-store + Pragma/Expires, как и положено SPA-входу с меняющимся контентом. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -437,7 +437,11 @@ app.get('/textbook/:slug', (req, res, next) => {
|
||||
const row = _stmtTextbookPath.get(req.params.slug);
|
||||
if (!row) return next();
|
||||
const filePath = path.join(frontendDir, 'textbooks', row.html_path);
|
||||
if (!isProd) res.setHeader('Cache-Control', 'no-store');
|
||||
// Страница-учебник — SPA-вход, контент меняется при обновлениях: не кэшируем html
|
||||
// ни в dev, ни в prod (иначе браузер показывает устаревшую версию с пустыми билдерами).
|
||||
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
|
||||
res.setHeader('Pragma', 'no-cache');
|
||||
res.setHeader('Expires', '0');
|
||||
if (req.query.embed === '1') {
|
||||
const html = _renderEmbed(filePath, req.params.slug);
|
||||
if (html == null) return next();
|
||||
|
||||
Reference in New Issue
Block a user