summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-24 10:34:52 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-24 12:11:08 +0100
commitae0be7797fe5e693fa403355fcd136cdb2356cf5 (patch)
tree4372c16434f32b455c7f6da0ca2f267c15b11365 /Userland/Libraries/LibWeb
parent712f76c0108627f38b777cb839c99e3c3a2f05cc (diff)
downloadserenity-ae0be7797fe5e693fa403355fcd136cdb2356cf5.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
index 14f3fd68d3..ab39743fd8 100644
--- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -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,