1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:37:35 +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:
Andreas Kling 2021-01-24 10:34:52 +01:00
parent 712f76c010
commit ae0be7797f

View file

@ -78,6 +78,9 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
if (!request.is_valid())
return nullptr;
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) {
@ -87,9 +90,11 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
return it->value;
}
}
}
auto resource = Resource::create({}, type, request);
if (use_cache)
s_resource_cache.set(request, resource);
load(