LibWebView+RequestServer: Support clearing the HTTP disk cache

This is a bit of a blunt hammer, but this hooks an action to clear the
HTTP disk cache into the existing Clear Cache action. Upon invocation,
it stops all existing cache entries from making further progress, and
then deletes the entire cache index and all cache files.

In the future, we will of course want more fine-grained control over
cache deletion, e.g. via an about:history page.
This commit is contained in:
Timothy Flynn 2025-10-09 14:24:47 -04:00 committed by Andreas Kling
parent 42eaea1043
commit 163e8e5b44
Notes: github-actions[bot] 2025-10-14 11:41:38 +00:00
10 changed files with 84 additions and 10 deletions

View file

@ -25,6 +25,7 @@ ErrorOr<CacheIndex> CacheIndex::create(Database::Database& database)
Statements statements {};
statements.insert_entry = TRY(database.prepare_statement("INSERT OR REPLACE INTO CacheIndex VALUES (?, ?, ?, ?, ?, ?);"sv));
statements.remove_entry = TRY(database.prepare_statement("DELETE FROM CacheIndex WHERE cache_key = ?;"sv));
statements.remove_all_entries = TRY(database.prepare_statement("DELETE FROM CacheIndex;"sv));
statements.select_entry = TRY(database.prepare_statement("SELECT * FROM CacheIndex WHERE cache_key = ?;"sv));
statements.update_last_access_time = TRY(database.prepare_statement("UPDATE CacheIndex SET last_access_time = ? WHERE cache_key = ?;"sv));
@ -60,6 +61,12 @@ void CacheIndex::remove_entry(u64 cache_key)
m_entries.remove(cache_key);
}
void CacheIndex::remove_all_entries()
{
m_database.execute_statement(m_statements.remove_all_entries, {});
m_entries.clear();
}
void CacheIndex::update_last_access_time(u64 cache_key)
{
auto entry = m_entries.get(cache_key);