LibWeb+WebContent: Rename the http-cache flag to http-memory-cache

Rather than having http-cache and http-disk-cache, let's rename the
former to http-memory-cache to be extra clear what we are talking about.
This commit is contained in:
Timothy Flynn 2025-12-01 15:11:27 -05:00 committed by Andreas Kling
parent b376ab4e81
commit adcf5462af
Notes: github-actions[bot] 2025-12-02 11:21:10 +00:00
10 changed files with 31 additions and 33 deletions

View file

@ -106,8 +106,8 @@
# cmakedefine01 HTML_SCRIPT_DEBUG
#endif
#ifndef HTTP_CACHE_DEBUG
# cmakedefine01 HTTP_CACHE_DEBUG
#ifndef HTTP_MEMORY_CACHE_DEBUG
# cmakedefine01 HTTP_MEMORY_CACHE_DEBUG
#endif
#ifndef HTTPJOB_DEBUG

View file

@ -70,7 +70,7 @@
namespace Web::Fetch::Fetching {
bool g_http_cache_enabled = false;
bool g_http_memory_cache_enabled = false;
#define TRY_OR_IGNORE(expression) \
({ \
@ -1424,14 +1424,14 @@ public:
// - the presented target URI (Section 7.1 of [HTTP]) and that of the stored response match, and
auto it = m_cache.find(url);
if (it == m_cache.end()) {
dbgln_if(HTTP_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m {}", url);
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m {}", url);
return {};
}
auto const& cached_response = it->value;
// - the request method associated with the stored response allows it to be used for the presented request, and
if (method != cached_response->method()) {
dbgln_if(HTTP_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m (Bad method) {}", url);
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m (Bad method) {}", url);
return {};
}
@ -1445,7 +1445,7 @@ public:
// + allowed to be served stale (see Section 4.2.4), or
// + successfully validated (see Section 4.3).
dbgln_if(HTTP_CACHE_DEBUG, "\033[32;1mHTTP CACHE HIT!\033[0m {}", url);
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[32;1mHTTP CACHE HIT!\033[0m {}", url);
return cached_response->clone(realm);
}
@ -1498,7 +1498,7 @@ private:
// https://fetch.spec.whatwg.org/#determine-the-http-cache-partition
static RefPtr<CachePartition> determine_the_http_cache_partition(Infrastructure::Request const& request)
{
if (!g_http_cache_enabled)
if (!g_http_memory_cache_enabled)
return nullptr;
// 1. Let key be the result of determining the network partition key given request.
@ -1905,7 +1905,7 @@ GC::Ref<PendingResponse> http_network_or_cache_fetch(JS::Realm& realm, Infrastru
// 4. If the revalidatingFlag is set and forwardResponses status is 304, then:
if (revalidating_flag->value() && forward_response->status() == 304) {
dbgln_if(HTTP_CACHE_DEBUG, "\033[34;1mHTTP CACHE REVALIDATE (304)\033[0m {}", http_request->current_url());
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[34;1mHTTP CACHE REVALIDATE (304)\033[0m {}", http_request->current_url());
// 1. Update storedResponses header list using forwardResponses header list, as per the "Freshening
// Stored Responses upon Validation" chapter of HTTP Caching.
@ -2524,17 +2524,17 @@ void append_fetch_metadata_headers_for_request(Infrastructure::Request& request)
set_sec_fetch_user_header(request);
}
void set_http_cache_enabled(bool const enabled)
void set_http_memory_cache_enabled(bool const enabled)
{
g_http_cache_enabled = enabled;
g_http_memory_cache_enabled = enabled;
}
bool http_cache_enabled()
bool http_memory_cache_enabled()
{
return g_http_cache_enabled;
return g_http_memory_cache_enabled;
}
void clear_http_cache()
void clear_http_memory_cache()
{
HTTPCache::the().clear_cache();
}

View file

@ -55,8 +55,8 @@ void set_sec_fetch_site_header(Infrastructure::Request&);
void set_sec_fetch_user_header(Infrastructure::Request&);
void append_fetch_metadata_headers_for_request(Infrastructure::Request&);
WEB_API void set_http_cache_enabled(bool enabled);
WEB_API bool http_cache_enabled();
WEB_API void clear_http_cache();
WEB_API void set_http_memory_cache_enabled(bool enabled);
WEB_API bool http_memory_cache_enabled();
WEB_API void clear_http_memory_cache();
}

View file

@ -301,8 +301,8 @@ void Internals::expire_cookies_with_time_offset(WebIDL::LongLong seconds)
bool Internals::set_http_memory_cache_enabled(bool enabled)
{
auto was_enabled = Web::Fetch::Fetching::http_cache_enabled();
Web::Fetch::Fetching::set_http_cache_enabled(enabled);
auto was_enabled = Web::Fetch::Fetching::http_memory_cache_enabled();
Web::Fetch::Fetching::set_http_memory_cache_enabled(enabled);
return was_enabled;
}

View file

@ -117,7 +117,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
bool log_all_js_exceptions = false;
bool disable_site_isolation = false;
bool enable_idl_tracing = false;
bool disable_http_cache = false;
bool disable_http_memory_cache = false;
bool enable_http_disk_cache = false;
bool disable_content_filter = false;
bool enable_autoplay = false;
@ -168,7 +168,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
args_parser.add_option(disable_site_isolation, "Disable site isolation", "disable-site-isolation");
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
args_parser.add_option(disable_http_cache, "Disable HTTP cache", "disable-http-cache");
args_parser.add_option(disable_http_memory_cache, "Disable HTTP memory cache", "disable-http-memory-cache");
args_parser.add_option(enable_http_disk_cache, "Enable HTTP disk cache", "enable-http-disk-cache");
args_parser.add_option(disable_content_filter, "Disable content filter", "disable-content-filter");
args_parser.add_option(enable_autoplay, "Enable multimedia autoplay", "enable-autoplay");
@ -273,7 +273,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
.log_all_js_exceptions = log_all_js_exceptions ? LogAllJSExceptions::Yes : LogAllJSExceptions::No,
.disable_site_isolation = disable_site_isolation ? DisableSiteIsolation::Yes : DisableSiteIsolation::No,
.enable_idl_tracing = enable_idl_tracing ? EnableIDLTracing::Yes : EnableIDLTracing::No,
.enable_http_cache = disable_http_cache ? EnableHTTPCache::No : EnableHTTPCache::Yes,
.enable_http_memory_cache = disable_http_memory_cache ? EnableMemoryHTTPCache::No : EnableMemoryHTTPCache::Yes,
.expose_internals_object = expose_internals_object ? ExposeInternalsObject::Yes : ExposeInternalsObject::No,
.force_cpu_painting = force_cpu_painting ? ForceCPUPainting::Yes : ForceCPUPainting::No,
.force_fontconfig = force_fontconfig ? ForceFontconfig::Yes : ForceFontconfig::No,

View file

@ -110,8 +110,8 @@ static ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_proc
arguments.append("--disable-site-isolation"sv);
if (web_content_options.enable_idl_tracing == WebView::EnableIDLTracing::Yes)
arguments.append("--enable-idl-tracing"sv);
if (web_content_options.enable_http_cache == WebView::EnableHTTPCache::Yes)
arguments.append("--enable-http-cache"sv);
if (web_content_options.enable_http_memory_cache == WebView::EnableMemoryHTTPCache::Yes)
arguments.append("--enable-http-memory-cache"sv);
if (web_content_options.expose_internals_object == WebView::ExposeInternalsObject::Yes)
arguments.append("--expose-internals-object"sv);
if (web_content_options.force_cpu_painting == WebView::ForceCPUPainting::Yes)

View file

@ -119,7 +119,7 @@ enum class EnableIDLTracing {
Yes,
};
enum class EnableHTTPCache {
enum class EnableMemoryHTTPCache {
No,
Yes,
};
@ -163,7 +163,7 @@ struct WebContentOptions {
LogAllJSExceptions log_all_js_exceptions { LogAllJSExceptions::No };
DisableSiteIsolation disable_site_isolation { DisableSiteIsolation::No };
EnableIDLTracing enable_idl_tracing { EnableIDLTracing::No };
EnableHTTPCache enable_http_cache { EnableHTTPCache::No };
EnableMemoryHTTPCache enable_http_memory_cache { EnableMemoryHTTPCache::No };
ExposeInternalsObject expose_internals_object { ExposeInternalsObject::No };
ForceCPUPainting force_cpu_painting { ForceCPUPainting::No };
ForceFontconfig force_fontconfig { ForceFontconfig::No };

View file

@ -22,7 +22,7 @@ set(GIF_DEBUG ON)
set(HEAP_DEBUG ON)
set(HIGHLIGHT_FOCUSED_FRAME_DEBUG ON)
set(HTML_SCRIPT_DEBUG ON)
set(HTTP_CACHE_DEBUG ON)
set(HTTP_MEMORY_CACHE_DEBUG ON)
set(HTTPJOB_DEBUG ON)
set(HUNKS_DEBUG ON)
set(ICO_DEBUG ON)

View file

@ -387,7 +387,7 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
}
if (request == "clear-cache") {
Web::Fetch::Fetching::clear_http_cache();
Web::Fetch::Fetching::clear_http_memory_cache();
return;
}

View file

@ -80,7 +80,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
bool log_all_js_exceptions = false;
bool disable_site_isolation = false;
bool enable_idl_tracing = false;
bool enable_http_cache = false;
bool enable_http_memory_cache = false;
bool force_cpu_painting = false;
bool force_fontconfig = false;
bool collect_garbage_on_every_allocation = false;
@ -103,7 +103,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
args_parser.add_option(disable_site_isolation, "Disable site isolation", "disable-site-isolation");
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
args_parser.add_option(enable_http_memory_cache, "Enable HTTP cache", "enable-http-memory-cache");
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
args_parser.add_option(collect_garbage_on_every_allocation, "Collect garbage after every JS heap allocation", "collect-garbage-on-every-allocation");
@ -146,10 +146,8 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
if (disable_site_isolation)
WebView::disable_site_isolation();
if (enable_http_cache) {
Web::Fetch::Fetching::set_http_cache_enabled(true);
}
if (enable_http_memory_cache)
Web::Fetch::Fetching::set_http_memory_cache_enabled(true);
Web::Painting::set_paint_viewport_scrollbars(!disable_scrollbar_painting);