@decocms/start 0.25.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./src/index.ts",
@@ -722,6 +722,20 @@ export function createDecoWorkerEntry(
722
722
  const v = (env[cacheVersionEnv] as string) || "";
723
723
  if (v) hit.headers.set("X-Cache-Version", v);
724
724
  }
725
+ // Restore client-facing Cache-Control (the stored version uses sMaxAge
726
+ // as max-age for Cache API TTL, which would leak to the CDN auto-cache
727
+ // and cause stale HTML after deploys — the CDN caches under the raw URL,
728
+ // bypassing BUILD_HASH versioned keys).
729
+ const hitProfile = getProfile(url);
730
+ const hitHeaders = cacheHeaders(hitProfile);
731
+ for (const [k, v] of Object.entries(hitHeaders)) {
732
+ hit.headers.set(k, v);
733
+ }
734
+ // Prevent CDN from auto-caching this response under the raw URL.
735
+ // The Worker manages edge caching via caches.default with versioned keys;
736
+ // CDN auto-caching would bypass that versioning and serve stale HTML
737
+ // after deploys (referencing old CSS/JS fingerprinted filenames).
738
+ hit.headers.set("CDN-Cache-Control", "no-store");
725
739
  return hit;
726
740
  }
727
741
  } catch {
@@ -785,12 +799,21 @@ export function createDecoWorkerEntry(
785
799
  if (v) toReturn.headers.set("X-Cache-Version", v);
786
800
  }
787
801
 
802
+ // Prevent CDN from auto-caching this response under the raw URL.
803
+ // Edge caching is managed by the Worker via caches.default with
804
+ // BUILD_HASH-versioned keys; CDN auto-caching would bypass versioning
805
+ // and serve stale HTML after deploys.
806
+ toReturn.headers.set("CDN-Cache-Control", "no-store");
807
+
788
808
  // For Cache API storage, use sMaxAge as max-age since the Cache API
789
809
  // ignores s-maxage and only respects max-age for TTL decisions.
790
810
  if (cache) {
791
811
  try {
792
812
  const toStore = toReturn.clone();
793
813
  toStore.headers.set("Cache-Control", `public, max-age=${profileConfig.sMaxAge}`);
814
+ // Remove CDN-Cache-Control from stored version — it's only needed
815
+ // on the response to the client to prevent CDN auto-caching.
816
+ toStore.headers.delete("CDN-Cache-Control");
794
817
  ctx.waitUntil(cache.put(cacheKey, toStore));
795
818
  } catch {
796
819
  // Cache API unavailable — skip storing