mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 10:20:22 +00:00
This directive allows our disk cache to serve stale responses for a time indicated by the directive itself, while we revalidate the response in the background. Issuing requests that weren't initiated by a client is a new thing for RequestServer. In this implementation, we associate the request with the client that initiated the request to the stale cache entry. This adds a "background request" mode to the Request object, to prevent us from trying to send any of the revalidation response over IPC.
37 lines
773 B
C++
37 lines
773 B
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Badge.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/Weakable.h>
|
|
#include <LibHTTP/Forward.h>
|
|
|
|
namespace HTTP {
|
|
|
|
class CacheRequest : public Weakable<CacheRequest> {
|
|
public:
|
|
virtual ~CacheRequest() = default;
|
|
|
|
virtual bool is_revalidation_request() const = 0;
|
|
|
|
virtual void notify_request_unblocked(Badge<DiskCache>) = 0;
|
|
|
|
protected:
|
|
enum class CacheStatus : u8 {
|
|
Unknown,
|
|
NotCached,
|
|
WrittenToCache,
|
|
ReadFromCache,
|
|
};
|
|
|
|
Optional<CacheEntryReader&> m_cache_entry_reader;
|
|
Optional<CacheEntryWriter&> m_cache_entry_writer;
|
|
CacheStatus m_cache_status { CacheStatus::Unknown };
|
|
};
|
|
|
|
}
|