Commit 929927b
committed
perf(relay): strip CDN noise response headers to reduce per-request JSON payload
CDN stacks (Cloudflare, AWS, Fastly) attach metadata headers to every
response — report-to, nel, alt-svc, server-timing, cf-ray, origin-trial,
etc. — that add 400-700 bytes of JSON per GAS relay response for zero
benefit through a MITM proxy. The relay ignores them and the browser
never reads them. On a Cloudflare-backed page with 50 subresource
requests this wastes ~25-35 KB of transfer, ~40-50ms at 600 KB/s.
Rust side (config-driven):
- Add `strip_noise_response_headers: bool` to Config and TomlRelay,
default true. Controls the primary user-facing toggle via config.toml.
- Add NOISE_RESPONSE_HEADERS static in domain_fronter.rs listing the 12
useless header names.
- Update parse_relay_json() to accept a strip_noise bool and skip listed
headers in the output loop when enabled.
- Pass self.strip_noise_response_headers at both call sites in
do_relay_once_inner (h2 and h1 paths).
Code.gs side (GAS payload reduction):
- Add STRIP_NOISE_RESPONSE_HEADERS constant (default true) and
STRIP_RESPONSE_HEADERS lookup object near DIAGNOSTIC_MODE.
- Update _respHeaders() to filter the blocklist when the constant is
true, reducing the JSON payload that travels over the GAS->Rust leg.
- Both _doSingle and _doBatch call _respHeaders, so both relay paths
get the filter automatically.
The two layers are independent: Code.gs reduces GAS->Rust bandwidth;
the Rust config controls what the browser sees. Setting
strip_noise_response_headers = false in config.toml passes all headers
through to the browser regardless of what Code.gs sends.1 parent eb1d00c commit 929927b
3 files changed
Lines changed: 89 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
49 | 75 | | |
50 | 76 | | |
51 | 77 | | |
| |||
329 | 355 | | |
330 | 356 | | |
331 | 357 | | |
| 358 | + | |
332 | 359 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
338 | 372 | | |
339 | 373 | | |
340 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
436 | 446 | | |
437 | 447 | | |
438 | 448 | | |
| |||
563 | 573 | | |
564 | 574 | | |
565 | 575 | | |
| 576 | + | |
566 | 577 | | |
567 | 578 | | |
568 | 579 | | |
| |||
811 | 822 | | |
812 | 823 | | |
813 | 824 | | |
| 825 | + | |
| 826 | + | |
814 | 827 | | |
815 | 828 | | |
816 | 829 | | |
| |||
969 | 982 | | |
970 | 983 | | |
971 | 984 | | |
| 985 | + | |
972 | 986 | | |
973 | 987 | | |
974 | 988 | | |
| |||
997 | 1011 | | |
998 | 1012 | | |
999 | 1013 | | |
| 1014 | + | |
1000 | 1015 | | |
1001 | 1016 | | |
1002 | 1017 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
416 | 420 | | |
417 | 421 | | |
418 | 422 | | |
| |||
648 | 652 | | |
649 | 653 | | |
650 | 654 | | |
| 655 | + | |
651 | 656 | | |
652 | 657 | | |
653 | 658 | | |
| |||
2851 | 2856 | | |
2852 | 2857 | | |
2853 | 2858 | | |
2854 | | - | |
| 2859 | + | |
2855 | 2860 | | |
2856 | 2861 | | |
2857 | 2862 | | |
| |||
2960 | 2965 | | |
2961 | 2966 | | |
2962 | 2967 | | |
2963 | | - | |
| 2968 | + | |
2964 | 2969 | | |
2965 | 2970 | | |
2966 | 2971 | | |
| |||
5001 | 5006 | | |
5002 | 5007 | | |
5003 | 5008 | | |
| 5009 | + | |
| 5010 | + | |
| 5011 | + | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
5004 | 5028 | | |
5005 | | - | |
| 5029 | + | |
5006 | 5030 | | |
5007 | 5031 | | |
5008 | 5032 | | |
| |||
5084 | 5108 | | |
5085 | 5109 | | |
5086 | 5110 | | |
| 5111 | + | |
| 5112 | + | |
| 5113 | + | |
5087 | 5114 | | |
5088 | 5115 | | |
5089 | 5116 | | |
| |||
5905 | 5932 | | |
5906 | 5933 | | |
5907 | 5934 | | |
5908 | | - | |
| 5935 | + | |
5909 | 5936 | | |
5910 | 5937 | | |
5911 | 5938 | | |
| |||
6804 | 6831 | | |
6805 | 6832 | | |
6806 | 6833 | | |
6807 | | - | |
| 6834 | + | |
6808 | 6835 | | |
6809 | 6836 | | |
6810 | 6837 | | |
6811 | 6838 | | |
6812 | 6839 | | |
6813 | 6840 | | |
6814 | | - | |
| 6841 | + | |
6815 | 6842 | | |
6816 | 6843 | | |
6817 | 6844 | | |
| |||
6870 | 6897 | | |
6871 | 6898 | | |
6872 | 6899 | | |
6873 | | - | |
| 6900 | + | |
6874 | 6901 | | |
6875 | 6902 | | |
6876 | 6903 | | |
| |||
6938 | 6965 | | |
6939 | 6966 | | |
6940 | 6967 | | |
6941 | | - | |
| 6968 | + | |
6942 | 6969 | | |
6943 | 6970 | | |
6944 | 6971 | | |
| |||
0 commit comments