fixing compression

This commit is contained in:
Rizky 2024-12-11 11:17:14 +07:00
parent f3d020b031
commit e93779ebf7
4 changed files with 16 additions and 13 deletions

BIN
bun.lockb

Binary file not shown.

BIN
data/sqlite/session.db Normal file

Binary file not shown.

View File

@ -87,21 +87,23 @@ export const createResponse = (
}
}
if (opt?.high_compression) {
if (!cached && opt.cache_accept.toLowerCase().includes("gz")) {
const content_hash = simpleHash(content);
if (!g.cache.gz[content_hash]) {
g.cache.gz[content_hash] = Bun.gzipSync(content);
}
if (g.cache.gz[content_hash]) {
cached = true;
content = g.cache.gz[content_hash];
headers["content-encoding"] = "gzip";
if (opt.cache_accept.toLowerCase().includes("gz")) {
if (opt?.high_compression) {
if (!cached) {
const content_hash = simpleHash(content);
if (!g.cache.gz[content_hash]) {
g.cache.gz[content_hash] = Bun.gzipSync(content);
}
if (g.cache.gz[content_hash]) {
cached = true;
content = g.cache.gz[content_hash];
headers["content-encoding"] = "gzip";
}
}
} else {
content = Bun.gzipSync(content);
headers["content-encoding"] = "gzip";
}
} else {
content = Bun.gzipSync(content);
headers["content-encoding"] = "gzip";
}
}

View File

@ -79,6 +79,7 @@ export const createServer = async () => {
const url = new URL(req.url) as URL;
url.pathname = url.pathname.replace(/\/+/g, "/");
const prasi = {};
const index = prodIndex(g.deploy.config.site_id, prasi);