Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: use public cache for downloaded assets

Brad Barbin26e91bc1d3cd
diff --git a/apps/carbon/app/routes/file+/model+/public.$.tsx b/apps/carbon/app/routes/file+/model+/public.$.tsx
index 9bbb55e4e4..d1c0352cba 100644
--- a/apps/carbon/app/routes/file+/model+/public.$.tsx
+++ b/apps/carbon/app/routes/file+/model+/public.$.tsx
@@ -64,7 +64,9 @@ export let loader = async ({ params }: LoaderFunctionArgs) => {
const headers = new Headers({
"Content-Type": contentType,
- "Cache-Control": "private, max-age=31536000, immutable", // Cache for a year
+ "Cache-Control": "public, max-age=31536000, immutable",
+ "CDN-Cache-Control": "public, max-age=31536000, immutable",
+ "Vercel-CDN-Cache-Control": "public, max-age=31536000, immutable",
"Access-Control-Allow-Origin": "*", // Allow cross-origin requests
"Access-Control-Allow-Methods": "GET", // Only allow GET requests
"Access-Control-Allow-Headers": "Content-Type", // Allow Content-Type header
diff --git a/apps/carbon/app/routes/file+/preview+/$bucket.$.tsx b/apps/carbon/app/routes/file+/preview+/$bucket.$.tsx
index df1c52eea0..579b03b6ea 100644
--- a/apps/carbon/app/routes/file+/preview+/$bucket.$.tsx
+++ b/apps/carbon/app/routes/file+/preview+/$bucket.$.tsx
@@ -61,7 +61,9 @@ export let loader = async ({ request, params }: LoaderFunctionArgs) => {
const headers = new Headers({
"Content-Type": contentType,
- "Cache-Control": "private, max-age=31536000, immutable", // Cache for a year
+ "Cache-Control": "public, max-age=31536000, immutable",
+ "CDN-Cache-Control": "public, max-age=31536000, immutable",
+ "Vercel-CDN-Cache-Control": "public, max-age=31536000, immutable",
});
return new Response(fileData, { status: 200, headers });
};
diff --git a/apps/mes/app/routes/file+/preview+/$bucket.$.tsx b/apps/mes/app/routes/file+/preview+/$bucket.$.tsx
index df1c52eea0..579b03b6ea 100644
--- a/apps/mes/app/routes/file+/preview+/$bucket.$.tsx
+++ b/apps/mes/app/routes/file+/preview+/$bucket.$.tsx
@@ -61,7 +61,9 @@ export let loader = async ({ request, params }: LoaderFunctionArgs) => {
const headers = new Headers({
"Content-Type": contentType,
- "Cache-Control": "private, max-age=31536000, immutable", // Cache for a year
+ "Cache-Control": "public, max-age=31536000, immutable",
+ "CDN-Cache-Control": "public, max-age=31536000, immutable",
+ "Vercel-CDN-Cache-Control": "public, max-age=31536000, immutable",
});
return new Response(fileData, { status: 200, headers });
};