[object Object]

← back to Stars of Design

sod-cache-stats

571d2899314ca0c9c6d13b0050e60e716eaca2fb · 2026-05-12 23:03:25 -0700 · Steve Abrams

Files touched

Diff

commit 571d2899314ca0c9c6d13b0050e60e716eaca2fb
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 12 23:03:25 2026 -0700

    sod-cache-stats
---
 routes/public.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/routes/public.js b/routes/public.js
index 5c8a436..787fb09 100644
--- a/routes/public.js
+++ b/routes/public.js
@@ -353,6 +353,9 @@ router.get('/api/clients/:id/comments', async (req, res, next) => {
 // (excluding Manufacturer Reps which are gated out everywhere else too).
 router.get('/api/stats', async (_req, res, next) => {
   try {
+    // 30s Cache-Control + 60s SWR so the endpoint can absorb status-loop
+    // polling + dashboard refreshes without hammering pg every hit.
+    res.setHeader('Cache-Control', 'public, max-age=30, stale-while-revalidate=60');
     const r = await statsPool.query(`
       SELECT
         (SELECT count(*) FROM sod_designers WHERE role IS NULL OR role <> 'Manufacturer Rep') AS designers,

← 0954ae8 starsofdesign: Cache-Control public max-age=3600 on /sitemap  ·  back to Stars of Design  ·  sod-comments-cache 4682bab →