Commit 5ceb59c
committed
Optimize cache miss path with deferred cache write (configurable)
Add configuration option proxy.config.http.cache.defer_write_on_miss
(default: 0/disabled) to defer opening the cache for write until after
response headers are received and evaluated for cacheability.
When enabled, this optimization:
- Avoids unnecessary cache overhead for non-cacheable responses
- Can improve throughput ~21x for non-cacheable content
Trade-offs when enabled:
- May affect read-while-write functionality
- May reduce request coalescing for popular uncached URLs
- Recommended only for traffic patterns with mostly unique URLs
or predominantly non-cacheable content
The optimization works by:
1. On cache miss, set cache_open_write_deferred=true instead of
immediately opening cache for write
2. Go to origin and fetch response headers
3. Check if response is cacheable:
- If not cacheable (no-store, etc.): skip cache write entirely
- If cacheable: open cache for write and proceed normally1 parent 855eb10 commit 5ceb59c
File tree
5 files changed
+99
-0
lines changed- configs
- include/proxy/http
- src/proxy/http
5 files changed
+99
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
581 | 586 | | |
582 | 587 | | |
583 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
696 | 700 | | |
697 | 701 | | |
698 | 702 | | |
| |||
997 | 1001 | | |
998 | 1002 | | |
999 | 1003 | | |
| 1004 | + | |
1000 | 1005 | | |
1001 | 1006 | | |
1002 | 1007 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
| 1090 | + | |
1090 | 1091 | | |
1091 | 1092 | | |
1092 | 1093 | | |
| |||
1391 | 1392 | | |
1392 | 1393 | | |
1393 | 1394 | | |
| 1395 | + | |
1394 | 1396 | | |
1395 | 1397 | | |
1396 | 1398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3231 | 3231 | | |
3232 | 3232 | | |
3233 | 3233 | | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
3234 | 3290 | | |
3235 | 3291 | | |
3236 | 3292 | | |
| |||
3276 | 3332 | | |
3277 | 3333 | | |
3278 | 3334 | | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
3279 | 3342 | | |
3280 | 3343 | | |
3281 | 3344 | | |
| |||
4677 | 4740 | | |
4678 | 4741 | | |
4679 | 4742 | | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
| 4747 | + | |
| 4748 | + | |
| 4749 | + | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
4680 | 4761 | | |
4681 | 4762 | | |
4682 | 4763 | | |
| |||
0 commit comments