You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Control HTTP caching of static assets served by client() #8
client() (src/handlers/client.ts) serves the application bundle through express.static with default options,
so every file, including content-hashed bundles, is served with Cache-Control: public, max-age=0. Observed on
@metreeca/gate 0.13.0:
Resource
Cache-Control
index.html / SPA navigation
public, max-age=0
hashed bundles (index-*.js/css)
public, max-age=0
unhashed public files (docs, images)
public, max-age=0
Every page load revalidates every bundle, and downstream caches (Cloud CDN, Firebase Hosting) store nothing.
proposal
Let client() apply a cache policy per resource class:
index.html: no-cache, so deploys are picked up immediately
Hashed files are identified by an application-declared path prefix, e.g. client(path, { immutable: "/_/" }),
matched to the build's assetsDir, rather than guessed from file names.
alternatives
Detecting hashed files by matching the bundler's hash suffix in file names: needs no application change, but is
fragile across bundler versions and naming configurations.
Setting headers in each application ahead of client(): works, but duplicates the policy in every consumer.
notes
Downstream, ec2u/pipe would switch assetsDir in packages/client/vite.config.ts to a dedicated directory to adopt it.
Activity