mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:37:34 +00:00
LibWeb: Disable resource cache for file:// URLs
This makes the browser a bit less annoying when testing local files, since you no longer have to restart it for changes to take effect. Longer-term we should have a proper way to decide which resources are cacheable.
This commit is contained in:
parent
712f76c010
commit
ae0be7797f
1 changed files with 13 additions and 8 deletions
|
@ -78,19 +78,24 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
|
|||
if (!request.is_valid())
|
||||
return nullptr;
|
||||
|
||||
auto it = s_resource_cache.find(request);
|
||||
if (it != s_resource_cache.end()) {
|
||||
if (it->value->type() != type) {
|
||||
dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url());
|
||||
} else {
|
||||
dbgln<debug_cache>("Reusing cached resource for: {}", request.url());
|
||||
return it->value;
|
||||
bool use_cache = request.url().protocol() != "file";
|
||||
|
||||
if (use_cache) {
|
||||
auto it = s_resource_cache.find(request);
|
||||
if (it != s_resource_cache.end()) {
|
||||
if (it->value->type() != type) {
|
||||
dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url());
|
||||
} else {
|
||||
dbgln<debug_cache>("Reusing cached resource for: {}", request.url());
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto resource = Resource::create({}, type, request);
|
||||
|
||||
s_resource_cache.set(request, resource);
|
||||
if (use_cache)
|
||||
s_resource_cache.set(request, resource);
|
||||
|
||||
load(
|
||||
request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue