fix
This commit is contained in:
parent
9e239c1d78
commit
398f9e6926
|
|
@ -12,6 +12,7 @@ import { g } from "utils/global";
|
|||
import brotliPromise from "brotli-wasm";
|
||||
import mime from "mime";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
export const _ = {
|
||||
url: "/prod/:site_id/**",
|
||||
async api() {
|
||||
|
|
@ -255,10 +256,15 @@ export const _ = {
|
|||
g.br = await brotliPromise;
|
||||
}
|
||||
setTimeout(() => {
|
||||
g.route_cache[site_id] = g.br.compress(res);
|
||||
if (!g.route_cache_compressing)
|
||||
g.route_cache_compressing = new Set();
|
||||
if (g.route_cache_compressing.has(site_id)) return;
|
||||
g.route_cache_compressing.add(site_id);
|
||||
g.route_cache[site_id] = g.br.compress(encoder.encode(res));
|
||||
g.route_cache_compressing.delete(site_id);
|
||||
}, 100);
|
||||
|
||||
return new Response(res, {
|
||||
return new Response(await gzipAsync(res), {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"content-encoding": "gzip",
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
apiProxy,
|
||||
} from "../../../app/web/src/base/load/api/api-proxy";
|
||||
import { dbProxy } from "../../../app/web/src/base/load/db/db-proxy";
|
||||
import { BrotliWasmType } from "brotli-wasm";
|
||||
|
||||
type SingleRoute = {
|
||||
url: string;
|
||||
|
|
@ -59,11 +60,12 @@ export const g = global as unknown as {
|
|||
Y: typeof Y;
|
||||
syncronize: typeof syncronize;
|
||||
static_cache: any;
|
||||
route_cache_compressing: Set<string>;
|
||||
route_cache: Record<string, any>;
|
||||
code_index_compressing: Set<string>;
|
||||
code_index_cache: Record<
|
||||
string,
|
||||
Record<string, { ts: number; content: any;type: string; }>
|
||||
>;
|
||||
br: any
|
||||
br: BrotliWasmType
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue