mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-05 02:20:54 +01:00
Improve caching quality for non-Discord non Telegram bots
This commit is contained in:
parent
91878e91c7
commit
0c2fe9d58b
1 changed files with 9 additions and 7 deletions
|
@ -7,13 +7,15 @@ export const cacheMiddleware = (): MiddlewareHandler => async (c, next) => {
|
|||
const request = c.req;
|
||||
const userAgent = request.header('User-Agent') ?? '';
|
||||
// https://developers.cloudflare.com/workers/examples/cache-api/
|
||||
const cacheUrl = new URL(
|
||||
userAgent.includes('Telegram')
|
||||
? `${request.url}&telegram`
|
||||
: userAgent.includes('Discord')
|
||||
? `${request.url}&discord`
|
||||
: request.url
|
||||
);
|
||||
let cacheUrl = new URL(request.url);
|
||||
|
||||
if (userAgent.includes('Telegram')) {
|
||||
cacheUrl = new URL(`${request.url}&telegram`);
|
||||
} else if (userAgent.includes('Discord')) {
|
||||
cacheUrl = new URL(`${request.url}&discord`);
|
||||
} else if (userAgent.match(Constants.BOT_UA_REGEX)) {
|
||||
cacheUrl = new URL(`${request.url}&bot`);
|
||||
}
|
||||
|
||||
console.log('cacheUrl', cacheUrl);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue