mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Perf: enforce more cache
This commit is contained in:
parent
1f23212042
commit
c85f9fac0c
@ -6,10 +6,19 @@ import { task, traceAsync } from './lib/trace-runner';
|
||||
import { SHARED_DESCRIPTION } from './lib/constants';
|
||||
import picocolors from 'picocolors';
|
||||
import { createMemoizedPromise } from './lib/memo-promise';
|
||||
import { TTL, deserializeArray, fsCache, serializeArray } from './lib/cache-filesystem';
|
||||
|
||||
export const getAppleCdnDomainsPromise = createMemoizedPromise(() => traceAsync(
|
||||
picocolors.gray('download dnsmasq-china-list apple.china.conf'),
|
||||
() => parseFelixDnsmasq('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf'),
|
||||
() => fsCache.apply(
|
||||
'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf',
|
||||
() => parseFelixDnsmasq('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf'),
|
||||
{
|
||||
ttl: TTL.THREE_DAYS(),
|
||||
serializer: serializeArray,
|
||||
deserializer: deserializeArray
|
||||
}
|
||||
),
|
||||
picocolors.gray
|
||||
));
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ export const TTL = {
|
||||
TEN_DAYS: () => randomInt(9, 11) * 24 * 60 * 60 * 1000
|
||||
};
|
||||
|
||||
const separator = String.fromCharCode(0);
|
||||
const separator = '\u0000';
|
||||
// const textEncoder = new TextEncoder();
|
||||
// const textDecoder = new TextDecoder();
|
||||
// export const serializeString = (str: string) => textEncoder.encode(str);
|
||||
|
||||
@ -7,8 +7,8 @@ export const HOSTS = [
|
||||
['https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt', false, false, TTL.THREE_DAYS()],
|
||||
// have not been updated for more than a year, so we set a 14 days cache ttl
|
||||
['https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt', true, false, TTL.TWO_WEEKS()],
|
||||
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt', false],
|
||||
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-Extension.txt', false],
|
||||
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt', false, false, TTL.THREE_DAYS()],
|
||||
['https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-AdBlock.txt', false, false, TTL.THREE_DAYS()],
|
||||
// ad-wars is not actively maintained, so we set a 7 days cache ttl
|
||||
['https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts', false, false, TTL.ONE_WEEK()],
|
||||
['https://raw.githubusercontent.com/durablenapkin/block/master/luminati.txt', true],
|
||||
@ -58,7 +58,7 @@ export const ADGUARD_FILTERS = [
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist.txt',
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist.txt'
|
||||
],
|
||||
12 * 60 * 60 * 1000
|
||||
TTL.TWLVE_HOURS()
|
||||
],
|
||||
// EasyPrivacy
|
||||
[
|
||||
@ -70,7 +70,7 @@ export const ADGUARD_FILTERS = [
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easyprivacy.txt',
|
||||
'https://ublockorigin.pages.dev/thirdparties/easyprivacy.txt'
|
||||
],
|
||||
12 * 60 * 60 * 1000
|
||||
TTL.TWLVE_HOURS()
|
||||
],
|
||||
// AdGuard DNS Filter
|
||||
[
|
||||
@ -78,7 +78,8 @@ export const ADGUARD_FILTERS = [
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/15_optimized.txt',
|
||||
'https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt'
|
||||
]
|
||||
],
|
||||
TTL.TWLVE_HOURS()
|
||||
],
|
||||
// uBlock Origin Filter List
|
||||
[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user