perf: omit search for immutable static requests (#13265)
* perf: omit search for immutable static requests * perf: also applies to /files * fix: exclude /proxy * /files/:key/*を301 redirectに --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
parent
50817df59c
commit
309a943528
3 changed files with 47 additions and 23 deletions
|
@ -34,6 +34,7 @@ import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
|||
import type { ChannelsRepository, ClipsRepository, FlashsRepository, GalleryPostsRepository, MiMeta, NotesRepository, PagesRepository, ReversiGamesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { deepClone } from '@/misc/clone.js';
|
||||
import { handleRequestRedirectToOmitSearch } from '@/misc/fastify-hook-handlers.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
|
@ -253,11 +254,16 @@ export class ClientServerService {
|
|||
|
||||
//#region vite assets
|
||||
if (this.config.clientManifestExists) {
|
||||
fastify.register(fastifyStatic, {
|
||||
root: viteOut,
|
||||
prefix: '/vite/',
|
||||
maxAge: ms('30 days'),
|
||||
decorateReply: false,
|
||||
fastify.register((fastify, options, done) => {
|
||||
fastify.register(fastifyStatic, {
|
||||
root: viteOut,
|
||||
prefix: '/vite/',
|
||||
maxAge: ms('30 days'),
|
||||
immutable: true,
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.addHook('onRequest', handleRequestRedirectToOmitSearch);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
const port = (process.env.VITE_PORT ?? '5173');
|
||||
|
@ -292,11 +298,16 @@ export class ClientServerService {
|
|||
decorateReply: false,
|
||||
});
|
||||
|
||||
fastify.register(fastifyStatic, {
|
||||
root: tarball,
|
||||
prefix: '/tarball/',
|
||||
immutable: true,
|
||||
decorateReply: false,
|
||||
fastify.register((fastify, options, done) => {
|
||||
fastify.register(fastifyStatic, {
|
||||
root: tarball,
|
||||
prefix: '/tarball/',
|
||||
maxAge: ms('30 days'),
|
||||
immutable: true,
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.addHook('onRequest', handleRequestRedirectToOmitSearch);
|
||||
done();
|
||||
});
|
||||
|
||||
fastify.get('/favicon.ico', async (request, reply) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue