diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 7042c479a1..88a7d238bd 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -453,6 +453,13 @@ Tab::Tab(Type type) m_web_content_view->debug_request("collect-garbage"); } })); + debug_menu.add_action(GUI::Action::create("Clear cache", { Mod_Ctrl | Mod_Shift, Key_C }, [this](auto&) { + if (m_type == Type::InProcessWebView) { + Web::ResourceLoader::the().clear_cache(); + } else { + m_web_content_view->debug_request("clear-cache"); + } + })); auto& help_menu = m_menubar->add_menu("Help"); help_menu.add_action(WindowActions::the().about_action()); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index f151a9cfab..49b5e48ce6 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -236,4 +236,10 @@ bool ResourceLoader::is_port_blocked(int port) return false; } +void ResourceLoader::clear_cache() +{ + dbgln("Clearing {} items from ResourceLoader cache", s_resource_cache.size()); + s_resource_cache.clear(); +} + } diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 5fe23adc8a..ad23dd8da1 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -56,6 +56,8 @@ public: const String& user_agent() const { return m_user_agent; } + void clear_cache(); + private: ResourceLoader(); static bool is_port_blocked(int port); diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index f47c13c5e3..22e08f3e9b 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -210,6 +211,10 @@ void ClientConnection::handle(const Messages::WebContentServer::DebugRequest& me m_page_host->set_should_show_line_box_borders(state); page().main_frame().set_needs_display(page().main_frame().viewport_rect()); } + + if (message.request() == "clear-cache") { + Web::ResourceLoader::the().clear_cache(); + } } void ClientConnection::handle(const Messages::WebContentServer::GetSource&)