Step 16 — Speed and reach¶
About 30 minutes. Branch: step-16.
The one new idea: the cache in front of you is configurable, and it is off unless you say otherwise.
Caching is opt-in¶
The default TTL is zero. Nothing is held. That is why nothing you have deployed so far has ever served anyone a stale page, and why turning caching on is a decision you make per path.
cache:
behaviors:
- path: /assets/*
ttl: 31536000
compress: true
- path: /index.html
ttl: 60
compress: true
Those two lines are the whole idea:
/assets/*for a year. Vite fingerprints those filenames — a changed file is a changed name. They cannot go stale, so hold them as long as possible./index.htmlfor sixty seconds. It is the file that names the current bundle. An edge holding an old copy keeps handing people a bundle you have replaced, and every asset it references 404s.
This is the most common way a deploy appears not to have worked
Cache index.html like an asset and your deploy is invisible — to some
people, for as long as the TTL, while working perfectly for you because your
edge happened to expire.
Fingerprinted files: long. The file that names them: short.
mecca cache status tally
mecca cache invalidate tally
mecca cache bypass tally web # every TTL to 0, while debugging
invalidate is the escape hatch; bypass is for when you are chasing something
and want the cache out of the way entirely.
Reach¶
The default excludes most of the world
standard |
North America and Europe — the default |
extended |
adds Africa, the Middle East, Asia |
global |
everywhere |
They are cumulative, not alternatives: extended is standard plus
more, not somewhere else.
If your visitors are in Africa, Asia or South America, standard means every
request crosses an ocean to reach a cache that was supposed to be near them.
Requests bill the same; only egress differs.
This is app-wide, not per service, because an app has one URL and one distribution behind it.
A name of its own¶
mecca domain add tally roadmap.example.com -s web
mecca domain verify tally roadmap.example.com
mecca domain list tally
add prints the DNS records to create. Once they resolve, a certificate is
issued and renewed for you.
Domains are added with a command, never in appmecca.yaml
A certificate has a lifecycle — issue, validate, renew, and fail in ways that
need reporting. That cannot be driven from a config file, which is why
domains: in the YAML does nothing.
This half needs DNS you control. If you have none, read it and move on; nothing later depends on it.
If it didn't work¶
| Symptom | Try | Usually |
|---|---|---|
| Deploy invisible to some people | mecca cache invalidate |
index.html cached too long |
| Still slow far away | mecca app show |
cdn.coverage still standard |
| Domain stuck pending | mecca domain verify |
DNS records not created, or not propagated |
| Cache config ignored | re-read the keys | cache: under the service, not the top level |