← back to Dw Photo Capture
Send Cache-Control: no-store on HTML so browsers never serve a stale page (was hiding the photo editor after deploy)
444a68341611e599cd05187607226eb401ad341e · 2026-06-24 16:18:09 -0700 · Steve Abrams
Files touched
Diff
commit 444a68341611e599cd05187607226eb401ad341e
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jun 24 16:18:09 2026 -0700
Send Cache-Control: no-store on HTML so browsers never serve a stale page (was hiding the photo editor after deploy)
---
server.js | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/server.js b/server.js
index 8fe868e..4c90fde 100644
--- a/server.js
+++ b/server.js
@@ -61,12 +61,18 @@ function gql(query, variables) {
return shopifyReq('POST', '/graphql.json', { query, variables: variables || {} }).then(r => (r.body || {}));
}
-function shopifyAttachImage(productId, dwSku, base64) {
+async function shopifyAttachImage(productId, dwSku, base64) {
const safe = (dwSku || ('SKU' + productId)).replace(/[^A-Za-z0-9._-]/g, '');
- return shopifyReq('POST', `/products/${productId}/images.json`, { image: { attachment: base64, filename: `${safe}.jpg` } })
- .then(r => (r.status >= 200 && r.status < 300)
- ? { ok: true, image_id: r.body && r.body.image && r.body.image.id }
- : { ok: false, err: `HTTP ${r.status}: ${(r.raw || '').slice(0, 160)}` });
+ // new photo becomes the FEATURED image (position 1) — so a re-shoot replaces the visible one
+ const r = await shopifyReq('POST', `/products/${productId}/images.json`,
+ { image: { attachment: base64, filename: `${safe}.jpg`, position: 1 } });
+ if (!(r.status >= 200 && r.status < 300)) return { ok: false, err: `HTTP ${r.status}: ${(r.raw || '').slice(0, 160)}` };
+ const newId = r.body && r.body.image && r.body.image.id;
+ // remove older images so the fresh photo is the only/primary one (clean re-shoot)
+ const all = await shopifyReq('GET', `/products/${productId}/images.json`);
+ const imgs = (all.body && all.body.images) || [];
+ for (const im of imgs) { if (im.id !== newId) await shopifyReq('DELETE', `/products/${productId}/images/${im.id}.json`); }
+ return { ok: true, image_id: newId };
}
// After a photo lands, make the SKU live IF it passes the activation gate
@@ -133,7 +139,9 @@ const server = http.createServer((req, res) => {
if (u.pathname === '/healthz') return send(res, 200, { ok: true });
if (u.pathname === '/' || u.pathname === '/index.html') {
- return res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }),
+ // no-store: the UI evolves fast and is read fresh per request — never let a
+ // browser serve a stale cached page (that hid the photo editor after a deploy).
+ return res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store, must-revalidate' }),
res.end(fs.readFileSync(path.join(ROOT, 'public/index.html')));
}
← 4b82a74 Roll: add Curl intensity slider + cycle Flat→Tube→Sheet (cur
·
back to Dw Photo Capture
·
auto-save: 2026-06-24T16:28:13 (4 files) — data/queue.json r 571e941 →