← back to Wallco Ai
/compare: ETag + 304 keyed on (catalog lastmod, view, ordered ids) — skip re-render when nothing changed
73f6770d0084553024fba237e4b4f402968ac7a4 · 2026-05-12 20:30:00 -0700 · SteveStudio2
Files touched
Diff
commit 73f6770d0084553024fba237e4b4f402968ac7a4
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue May 12 20:30:00 2026 -0700
/compare: ETag + 304 keyed on (catalog lastmod, view, ordered ids) — skip re-render when nothing changed
---
server.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/server.js b/server.js
index 5981985..d23c333 100644
--- a/server.js
+++ b/server.js
@@ -5808,6 +5808,13 @@ app.get('/compare', (req, res) => {
// ?view=grid or legacy ?grid=1 enables grid mode.
const view = (String(req.query.view || '').toLowerCase() === 'grid' || req.query.grid === '1') ? 'grid' : 'specs';
const idsQS = rawIds.join(',');
+ // Deterministic ETag — page output depends only on (catalog state, view, ids in order).
+ // Lets browsers/CDNs skip re-rendering when the comparison hasn't changed (the IDs +
+ // view are stable while a designer drags the link around / re-opens the tab).
+ const _cmpEtag = `"cmp-${CATALOG_LAST_MODIFIED.getTime()}-${view}-${idsQS || 'empty'}"`;
+ res.setHeader('ETag', _cmpEtag);
+ res.setHeader('Cache-Control', 'private, max-age=0, must-revalidate');
+ if (req.headers['if-none-match'] === _cmpEtag) return res.status(304).end();
const cellsForRow = (fn) => items.map(d => `<td style="padding:10px 14px;border-top:1px solid var(--line,#eee);font:13px var(--sans,system-ui);width:${colWidth};vertical-align:top">${fn(d)}</td>`).join('');
res.type('html').send(`${htmlHead({
title: 'Compare Designs — wallco.ai',
← 80b15e7 /me/saved: surface 'Saved Xh ago' badge per card (SELECT alr
·
back to Wallco Ai
·
drunk-animals: replace launchd plist with pm2 daemon for pre 5308324 →