mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-03 16:10:29 +00:00
cache: add debug log with no store reason
This commit is contained in:
33
src/network/cache/Cache.zig
vendored
33
src/network/cache/Cache.zig
vendored
@@ -17,6 +17,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const log = @import("../../log.zig");
|
||||||
const Http = @import("../http.zig");
|
const Http = @import("../http.zig");
|
||||||
const FsCache = @import("FsCache.zig");
|
const FsCache = @import("FsCache.zig");
|
||||||
|
|
||||||
@@ -171,11 +172,33 @@ pub fn tryCache(
|
|||||||
has_set_cookie: bool,
|
has_set_cookie: bool,
|
||||||
has_authorization: bool,
|
has_authorization: bool,
|
||||||
) !?CachedMetadata {
|
) !?CachedMetadata {
|
||||||
if (status != 200) return null;
|
if (status != 200) {
|
||||||
if (has_set_cookie) return null;
|
log.debug(.cache, "no store", .{ .url = url, .code = status, .reason = "status" });
|
||||||
if (has_authorization) return null;
|
return null;
|
||||||
if (vary) |v| if (std.mem.eql(u8, v, "*")) return null;
|
}
|
||||||
const cc = CacheControl.parse(cache_control orelse return null) orelse return null;
|
if (has_set_cookie) {
|
||||||
|
log.debug(.cache, "no store", .{ .url = url, .reason = "has_cookies" });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (has_authorization) {
|
||||||
|
log.debug(.cache, "no store", .{ .url = url, .reason = "has_authorization" });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (vary) |v| if (std.mem.eql(u8, v, "*")) {
|
||||||
|
log.debug(.cache, "no store", .{ .url = url, .vary = v, .reason = "vary" });
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
const cc = blk: {
|
||||||
|
if (cache_control == null) {
|
||||||
|
log.debug(.cache, "no store", .{ .url = url, .reason = "no cache control" });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (CacheControl.parse(cache_control.?)) |cc| {
|
||||||
|
break :blk cc;
|
||||||
|
}
|
||||||
|
log.debug(.cache, "no store", .{ .url = url, .cache_control = cache_control.?, .reason = "cache control" });
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.url = try arena.dupeZ(u8, url),
|
.url = try arena.dupeZ(u8, url),
|
||||||
|
|||||||
Reference in New Issue
Block a user