Operations

Caching strategy for pages, assets, and read-only responses

Use these headers at the edge for every resource class. The same rule applies on every page, so a change reaches visitors promptly and a repeated check does not reuse a stale result.

The rule that governs every class

Files whose names do not change between versions, such as site.css, theme.css, site.js, app.css, app.js, and the component scripts /components/download.js, /components/saved-items.js, /components/offline-reload.js, /components/search-match.js, /grounding-guardrail.js, and /try-sample.js, never get long-lived browser or edge caching. Content-hashed files under /assets/ can be cached for one year. HTML and read-only API responses are revalidated or not stored, so a deploy or a fresh check is not hidden by a cache. Edge and Worker rules must match by resource pattern and file extension, not by an enumerated exact path list alone, so a new HTML route, a new script under /app/ or /components/, or a new root CSS or JavaScript file automatically falls in the correct class below and never gets immutable or long-lived caching by default. A query string on a static asset does not move it to the hashed class.

  • Set headers at the Worker or CDN edge. A Cache-Control meta tag in HTML is not a substitute for a response header and is not used on these pages.
  • Send a strong ETag on every cacheable static file. A changed file must send a changed ETag, so a revalidation returns 304 only when the bytes are the same. Generate the ETag from the file bytes. Do not generate an ETag from a file name, a modification time alone, or a random value per request, and do not reuse an ETag across different URLs.
  • Never cache a signed-in API response in a shared cache. Keep signed-in responses private and do not reuse them across people or colleges. The CDN must bypass /api/* for signed-in routes, not store a response even when a client sends a conditional request.

Headers, lifetimes, and invalidation by resource class

Copy each row into the edge rules for the pattern shown, with the examples as checks. Lifetimes are maximum ages for a browser or edge cache before revalidation.

Cache-Control, ETag, CDN lifetime, and invalidation for each resource class
Resource classPaths in this packCache-Control to sendETag and revalidationCDN lifetime and invalidation
HTML documentsPattern: every HTML document route. Examples in this pack: / , /features, /about, /assistants, /sources, /widget, /reports, /security, /accessibility, /status, /operations, /request-demo, /my-answers, /offline, /guides/ and /guides/*, /app/ , /caching, and every other public page route that serves HTMLpublic, max-age=0, must-revalidateStrong ETag. Browser revalidates on each load. A 304 keeps the page only when the HTML bytes are unchanged. The signed-in app shell at /app/ holds no workspace data in its HTML. Workspace data arrives only through signed-in API responses below, which are never cached. The shell still revalidates on each load so a new unhashed app script is picked up.Edge max-age=0, stale-while-revalidate=0. Invalidation: a deploy replaces HTML at once. No manual purge is needed, because no edge copy is kept.
Unhashed CSS and JavaScriptPattern: any CSS or JavaScript file whose name does not change between versions, at the public root, under /app/ including view and helper modules, and under /components/. Examples: /site.css, /theme.css, /site.js, /app/app.css, /app/app.js, any module under /app/views/, /components/download.js, /components/saved-items.js, /components/offline-reload.js, /components/search-match.js, /grounding-guardrail.js, /try-sample.jspublic, max-age=300, must-revalidateStrong ETag generated from file bytes. After 300 seconds the browser revalidates with If-None-Match. A changed file sends a new ETag and a 200 response. A query string does not make this class immutable.Edge max-age=300, stale-while-revalidate=0. Invalidation: a deploy changes the file bytes and the ETag. Visitors get the new file within 300 seconds, or sooner on a hard reload. No stale copy is served after expiry, so a deploy is not hidden by stale-while-revalidate. Never use immutable for these paths.
Content-hashed assets/assets/* with a content hash in the file namepublic, max-age=31536000, immutableETag optional. Immutable means no revalidation is needed, because a new version uses a new file name.Edge max-age=31536000, immutable. Invalidation: publish a new hashed file name. The old file can stay cached, because no page links to it after the deploy.
Icons and manifestPattern: /icons/* and /manifest.webmanifest. Examples: /icons/icon.svg, /icons/icon-192.png, /manifest.webmanifestpublic, max-age=86400, must-revalidateStrong ETag generated from file bytes. Revalidate after 86400 seconds with If-None-Match.Edge max-age=86400, stale-while-revalidate=0. Invalidation: replace the file and change the ETag. Visitors get the new file within 86400 seconds, with no stale copy served after expiry. Icons under /assets/ with a hash follow the hashed row instead.
Service worker file/sw.jspublic, max-age=0, must-revalidateStrong ETag. The browser checks for a new service worker on each navigation.Edge max-age=0. Invalidation: a deploy replaces the file. Never set a long lifetime, because a cached service worker would keep an old app shell.
Read-only live check/api/healthprivate, no-storeNo ETag. No conditional reuse. Each check is a fresh request with no sign-in and no cookies, with an 8000 millisecond timeout as documented on /status and /operations.Edge no-store and bypass. No shared cache, no stale copy, and no polling. Invalidation does not apply, because nothing is stored.
Signed-in readiness check/api/readinessprivate, no-storeNo ETag. No conditional reuse. Signed-in staff only, never called from the public status page. A 401 or 403 answer carries no data field and no checks object, because no check was run.Edge no-store and bypass. No shared cache, no stale copy, and no polling. Invalidation does not apply, because nothing is stored.
Public form endpoint/api/public/requestprivate, no-storeNo ETag. A POST is never cached and never reused. A retry reuses the same request reference from site.js, so it does not create a duplicate request.Edge no-store and bypass. Invalidation does not apply. Keep the 30000 millisecond submit timeout documented on /operations.
Signed-in APIPattern: /api/* other than /api/health, /api/readiness, and /api/public/requestprivate, no-storeNo ETag, no Expires date, and no shared ETag reuse across people or colleges. A response is for one signed-in workspace only. The Worker must not add an ETag or a public Cache-Control value to these responses.Edge bypass and no-store, no shared cache. The CDN must not store a signed-in response, even on a conditional request, and must ignore If-None-Match for /api/* and must not return 304 from a shared cache. Invalidation: none, because no copy is kept. A role or workspace change takes effect on the next request.

Cache keys by resource class

Use this key at the edge for every request. The key decides which stored copy, if any, a request can reuse. Public pages are the same for every visitor, so the public key holds no sign-in or workspace part. Private responses hold no stored copy, so they hold no shared key.

Cache key, parts included, and parts excluded for each resource class
Resource classCache key to useParts included in the keyParts excluded from the key
HTML documentsGET plus normalized path. The home path is / . A guide path is /guides/ and /guides/ plus the guide slug. A trailing slash is removed except for / .Method GET and the normalized path only.Query string, hash fragment, Cookie, Authorization, and sign-in state. A search word in the address, such as ?q= on /guides/, does not create a new public copy, because the guides and terminology filters run in the browser on the same HTML.
Unhashed CSS and JavaScriptGET plus exact path, such as /site.css, /theme.css, /site.js, /app/app.css, /app/app.js, and each component script path listed in the table above.Method GET and the exact file path only.Query string, hash fragment, Cookie, and Authorization. A changed file keeps the same key and a new ETag, so revalidation decides reuse.
Content-hashed assetsGET plus exact hashed file path under /assets/ , with the hash in the file name as part of the key.Method GET and the full hashed file name.Query string, hash fragment, Cookie, and Authorization. A new version is a new key, because the file name changes.
Icons and manifestGET plus exact path, such as /icons/icon.svg, /icons/icon-192.png, and /manifest.webmanifest.Method GET and the exact file path only.Query string, hash fragment, Cookie, and Authorization.
Service worker fileGET plus /sw.js only. The registration scope is not part of the file key.Method GET and /sw.js only.Query string, hash fragment, Cookie, and Authorization.
Read-only live check, signed-in readiness check, public form endpoint, and signed-in APINo cache key. Bypass the cache for every request. Do not store a copy under method plus path, and do not share a copy across people or colleges.No part is stored for reuse.Tenant, role, Cookie, and Authorization are never used to build a shared key, because no shared copy exists. A POST to /api/public/request is never reused under any key.
  • Do not add Cookie or Authorization to a public key, and do not add a sign-in or workspace part to a public key. A visitor without an account and a signed-in person share the same public HTML and asset copies.
  • Do not send Vary: Cookie or Vary: Authorization on a public class to split the public copy by sign-in. Private classes are not stored, so they need no Vary split.
  • A conditional request uses the ETag stored under the key above. A request with a different key must not reuse the ETag or body from another key.

Invalidation tied to content updates

Use this table when a page, a guide, an asset, or signed-in data changes. No row needs a manual purge, because the lifetime and ETag in the table above decide reuse on the next load.

Content update, paths affected, and how a visitor gets the new copy
Content updatePaths whose stored copy changesHow a visitor gets the new copyManual purge needed
Marketing page text changes in a deploy, such as Features, Assistants, Reports, or a guide pageThe HTML path for that page only, under its key in the table above. Other HTML paths keep the same bytes and the same ETag.HTML is public, max-age=0, must-revalidate, with edge max-age=0 and stale-while-revalidate=0. The browser revalidates on the next load. A 304 keeps the page only when the bytes are unchanged. A 200 replaces the copy with the new HTML.No. No edge copy is kept for HTML.
A new guide is added, or a guide title or card changesThe new guide path /guides/ plus the guide slug is a new key. The guides index path /guides/ changes in the same deploy when its card list changes.The new guide key has no stored copy, so the first load fetches it. The guides index revalidates on the next load under the HTML rule above, so the new card appears with the new index HTML.No. Do not purge other guide paths, because their bytes and ETags are unchanged.
Unhashed CSS or JavaScript changes, such as site.css, theme.css, site.js, app.css, app.js, or a component scriptThe same file path and the same key. The bytes change, so the ETag changes in the same deploy.Browser revalidates after 300 seconds with If-None-Match, and the edge revalidates after 300 seconds with stale-while-revalidate=0. No stale copy is served after expiry. A hard reload gets the new file at once. A 304 is returned only when the bytes are unchanged.No. Never use immutable for these paths, because the name does not change between versions.
Content-hashed asset changes under /assets/A new hashed file name is a new key. Pages in the same deploy link to the new name. The old key is no longer linked.The browser fetches the new key once and caches it for 31536000 seconds as immutable. The old file can stay cached, because no page links to it after the deploy.No. Do not purge the old hashed key, and do not reuse its copy for the new key.
Icon or manifest changesThe same icon or manifest path and the same key. The bytes change, so the ETag changes.Revalidate after 86400 seconds with If-None-Match, with edge stale-while-revalidate=0. No stale copy is served after expiry. An icon under /assets/ with a hash follows the hashed asset row instead.No.
Service worker file changes/sw.js only, under its key. The bytes change, so the ETag changes.The browser checks for a new service worker on each navigation, because the file is public, max-age=0, must-revalidate. A deploy replaces the file at once.No. Never set a long lifetime on /sw.js.
Approved source, assistant, question, answer, or report data changes in the signed-in appNo public HTML or public asset path changes. Signed-in API paths under /api/ are not stored under any key.Each signed-in request runs fresh with private, no-store. A role, workspace, source, or assistant change takes effect on the next request, because no signed-in copy is kept.No. Public pages do not cache signed-in data, so no public purge can show new signed-in data.
Live check, readiness check, or public form result changes/api/health, /api/readiness, and /api/public/request hold no stored copy under any key.Each check runs fresh with private, no-store and no ETag. The status page runs /api/health on page load and only again when the person chooses Check again. A form POST is never cached and never reused.No. Invalidation does not apply, because nothing is stored.
  • When a content update and an asset update ship in the same deploy, each path follows its own row above. Do not purge a whole site for one changed file, and do not keep a long lifetime to hide the change.
  • When a guide, source, or assistant change is made only in the signed-in app and no public file is deployed, public HTML and assets do not change. Do not purge public pages for a signed-in data change.
  • When a file name does not change between versions, keep the short lifetime in the table above. When a file name holds a content hash, keep the long lifetime in the table above. That split is what lets a change reach visitors promptly without a purge.

Conditional requests with ETag

Use a conditional request only where the table above sends an ETag. Where the table sends no ETag, the client sends no conditional header and treats every answer as fresh.

  • Public cacheable classes, HTML, unhashed CSS and JavaScript, icons and manifest, and /sw.js: the browser stores the body with its strong ETag. After the stated maximum age, or on each load for HTML and /sw.js, the browser sends If-None-Match with the stored ETag. The server answers 304 with the same ETag only when the bytes are unchanged, and the browser keeps the stored copy only then. On a 200 answer the browser replaces the copy and stores the new ETag. Do not send If-None-Match with a guessed value, and do not use If-Modified-Since as a substitute for the ETag on these classes.
  • Content-hashed assets under /assets/: immutable means the browser does not revalidate and does not send If-None-Match, because a new version uses a new file name. An ETag if sent is not needed for reuse.
  • Private no-store classes, /api/health, /api/readiness, /api/public/request, and signed-in /api/ responses: no ETag is sent, the client sends no If-None-Match, the browser and the edge store nothing, and every request runs fresh. A 304 must not be treated as success for these endpoints. The status live check in status.html uses cache no-store with credentials omitted, the public form in site.js sends a POST that is never conditional and never reused, and readiness runs only with sign-in.
  • Do not add an ETag to a private response for shared reuse, and do not reuse a conditional answer across people or colleges. A role or workspace change takes effect on the next signed-in request, because no signed-in answer is stored. Generate a strong ETag from file bytes, include the path in the cache key, and do not reuse an ETag across URLs. For /api/* the CDN must ignore If-None-Match and must not return 304 from a shared cache.

Session reuse within one page load

These rules stop repeated identical high-cost fetches without storing a stale result.

  • Live check: site.js blocks a second check while one is running. Do not add sessionStorage reuse for /api/health, because /status states the check runs fresh with no stored details.
  • Static files: the browser cache handles repeat loads within 300 seconds for unhashed CSS and JavaScript, including app view modules under /app/, and within 86400 seconds for icons. No script on these pages refetches a static file by code, so no extra fetch guard is needed. HTML revalidation on each load is the intended cost so a deploy is not hidden. Do not add client-side HTML caching in a script to avoid it.
  • Form drafts: site.js saves a draft in sessionStorage with a 250 millisecond debounce. A draft is per tab and is not a cache of a server response.
  • Filters: the guides and terminology filters run in the browser with a 120 millisecond debounce. Typing does not repeat a server fetch.
  • No polling is set up for the live check or for the signed-in app load. A check runs on page load and only again when the person chooses Check again.

Verify after a deploy

Run each check after the edge rules are set. If a check fails, fix the edge rule before you publish.

  1. Check unhashed assets

    Run curl -I https://campus.appmajic.ai/site.css and confirm Cache-Control is public, max-age=300, must-revalidate, with an ETag header. Repeat for /site.js, /theme.css, /app/app.css, /app/app.js, /components/download.js, /components/saved-items.js, /components/offline-reload.js, /components/search-match.js, /grounding-guardrail.js, and /try-sample.js. Also check one JavaScript module under /app/views/ and confirm the same header, so a new app module cannot fall through to a default cache rule.

  2. Check HTML

    Run curl -I https://campus.appmajic.ai/ and confirm Cache-Control is public, max-age=0, must-revalidate. Repeat for https://campus.appmajic.ai/guides/get-started and https://campus.appmajic.ai/app/ and confirm the same header and a strong ETag.

  3. Check the live check

    Run curl -I https://campus.appmajic.ai/api/health and confirm Cache-Control is private, no-store, with no shared cache and no ETag.

  4. Check hashed assets

    Run curl -I for a file under /assets/ with a hash in its name and confirm Cache-Control is public, max-age=31536000, immutable.

  5. Check a changed file reaches the browser

    In a test deploy, change site.css, reload the page after 300 seconds and confirm the new file loads. Confirm a hard reload loads it at once, confirm the ETag changed, and confirm no stale copy is served after expiry, because stale-while-revalidate is 0 for this class.

  6. Check private endpoints

    Run the readiness check only with sign-in inside the signed-in app and confirm Cache-Control is private, no-store, with no ETag and no shared cache. Confirm POST /api/public/request is private, no-store, with no ETag. Confirm a signed-in /api/ response is private, no-store, is not reused across people or colleges, and is bypassed at the CDN, so a request with If-None-Match does not return 304. Confirm the public status page calls only /api/health and never calls /api/readiness.

  7. Check conditional requests

    For /site.css, save the ETag from curl -I, then run curl -I with If-None-Match set to that ETag and confirm 304 with the same ETag when the file is unchanged, and 200 with a new ETag after a deploy changes the file. For /api/health and for a signed-in /api/ route, confirm no ETag is sent and a request with If-None-Match does not return 304 as success.

  8. Check no stale copy after expiry

    For unhashed CSS and JavaScript and for icons and manifest, confirm the edge sends stale-while-revalidate=0 in the Cache-Control value, and confirm a request after the stated maximum age returns the current bytes with a current ETag, not a stale copy served while revalidating.

  9. Check cache keys

    Run curl -I for /features and for /features?q=search and confirm the same Cache-Control and the same ETag, so the query does not create a new public copy. Run curl -I for /site.css with and without a query string and confirm the same ETag under the same key. Confirm /api/health, /api/readiness, and a signed-in /api/ response send no ETag and no shared cache, so no key is stored for them.

  10. Check a content update with no purge

    In a test deploy, change one guide title and confirm the next load of /guides/ and of that guide path shows the new title with no manual purge. Confirm an unchanged guide path still returns 304 on revalidation, and confirm a signed-in data change does not require a public purge.

What not to do

Each item below would hide a deploy or reuse a stale result.

  • Do not set immutable or a one year lifetime on site.css, theme.css, site.js, app.css, app.js, /components/download.js, /components/saved-items.js, /components/offline-reload.js, /components/search-match.js, /grounding-guardrail.js, or /try-sample.js, because their names do not change between versions.
  • Do not cache /api/health, /api/public/request, or any signed-in /api/ response in a shared cache.
  • Do not set a long lifetime on /sw.js or on HTML documents.
  • Do not add a Cache-Control meta tag in HTML as a substitute for a response header.
  • Do not add polling for the live check to work around a cache. The check is manual only after the first run.
  • Do not add an ETag to /api/health, /api/readiness, /api/public/request, or signed-in /api/ responses, and do not send If-None-Match on those endpoints or reuse a conditional answer across people or colleges.
  • Do not set stale-while-revalidate on HTML, unhashed CSS and JavaScript, icons and manifest, or /sw.js, because a stale copy served after expiry would hide a deploy past the stated lifetime.
  • Do not match edge rules only to exact paths listed as examples. Match by pattern so new HTML routes and new scripts under /app/ and /components/ get the correct class.
  • Do not cache signed-in /api/* at the CDN, even with a private header, and do not add an ETag or Expires date to signed-in responses.
  • Do not treat a query string variant of an unhashed file as immutable, do not use a weak ETag for cacheable static files, and do not reuse an ETag across different URLs.
  • Do not add Cookie, Authorization, sign-in state, or workspace to a public cache key, and do not split a public copy by sign-in. Public pages are the same for every visitor.
  • Do not purge a whole site for one changed page or file, and do not keep a long lifetime to hide a deploy. Use the key and ETag for the changed path only, as in the invalidation table above.

Set the headers, then check the status page

Apply the table above at the edge, confirm each header with curl -I, and confirm the live check on the status page still runs fresh.