Commit 7e17085
feat(proxy): add cacheControl override; force immutable on VTEX /files/*?v=* (#1590)
The generic proxy handler in website/handlers/proxy.ts passes upstream
Cache-Control verbatim. For VTEX-proxied versioned static assets like
/files/checkout6-custom.css?v=920636e4 the upstream sends short TTLs,
even though the `?v=HASH` query param makes the content immutable by
definition. Production CDN data on lojastorra.com.br showed 51%-81%
expired rates on these checkout assets.
This commit adds an opt-in `cacheControl` prop on the proxy:
cacheControl?: {
value: string;
matchQueryParam?: string;
};
When `matchQueryParam` is set, the override applies only if the
incoming request URL has that param — letting us safely opt in only
versioned variants of a path. The override applies only to 2xx
responses so error pages keep their upstream cache semantics.
In vtex/loaders/proxy.ts, /files/*, /assets/*, /arquivos/* are now
wired to the override with `value: "public, max-age=31536000,
immutable"` and `matchQueryParam: "v"`. Unversioned requests on the
same paths keep upstream Cache-Control.
Follows the immutable-asset idiom already used in
website/loaders/asset.ts (s-maxage=15552000, max-age=15552000,
immutable).
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bb78556 commit 7e17085
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
80 | 97 | | |
81 | 98 | | |
82 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| |||
104 | 124 | | |
105 | 125 | | |
106 | 126 | | |
| 127 | + | |
107 | 128 | | |
108 | 129 | | |
109 | 130 | | |
| |||
218 | 239 | | |
219 | 240 | | |
220 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
221 | 249 | | |
222 | 250 | | |
223 | 251 | | |
| |||
0 commit comments