From 1a2002df32918d257af076afb8f576c013f16259 Mon Sep 17 00:00:00 2001 From: AdityaAtulTewari Date: Wed, 17 Jul 2024 13:35:03 -0500 Subject: [PATCH] Added compatibility flags to update --- src/workerd/api/http-test.wd-test | 2 +- src/workerd/api/http.c++ | 4 ++++ src/workerd/io/compatibility-date.capnp | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/workerd/api/http-test.wd-test b/src/workerd/api/http-test.wd-test index 2d147e52bb7..8a588eec931 100644 --- a/src/workerd/api/http-test.wd-test +++ b/src/workerd/api/http-test.wd-test @@ -11,7 +11,7 @@ const unitTests :Workerd.Config = ( ( name = "SERVICE", service = "http-test" ) ], compatibilityDate = "2023-08-01", - compatibilityFlags = ["nodejs_compat", "service_binding_extra_handlers"], + compatibilityFlags = ["nodejs_compat", "service_binding_extra_handlers", "cache_header_enabled"], ) ), ], diff --git a/src/workerd/api/http.c++ b/src/workerd/api/http.c++ index 6c2d5eda1f3..e4d8a792d33 100644 --- a/src/workerd/api/http.c++ +++ b/src/workerd/api/http.c++ @@ -1076,6 +1076,10 @@ jsg::Ref Request::constructor( } KJ_IF_SOME(c, initDict.cache) { + bool cacheHeaderEnabled = FeatureFlags::get(js).getCacheHeaderEnabled(); + if(!cacheHeaderEnabled) { + JSG_FAIL_REQUIRE(TypeError, kj::str("Unsupported cache mode: ", c, "\nYou may need to enable a compatability flag.")); + } cacheMode = getCacheModeFromName(c); } diff --git a/src/workerd/io/compatibility-date.capnp b/src/workerd/io/compatibility-date.capnp index 9573ea607ab..3425b4f6669 100644 --- a/src/workerd/io/compatibility-date.capnp +++ b/src/workerd/io/compatibility-date.capnp @@ -504,4 +504,10 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef { $compatDisableFlag("legacy_module_registry") $experimental; # Enables of the new module registry implementation. + + cacheHeaderEnabled @53 :Bool + $compatEnableFlag("cache_header_enabled") + $compatDisableFlag("cache_header_disabled") + $experimental; + # Enables the use of no-cache and no-store headers from requests }