perf: optimize admin pages for <50ms TTFB
- All 103 pages now serve with TTFB ≤ 12ms (target: 50ms) - Connection pool: max 10→50, timeout 10s→5s (eliminates 30s admin page timeouts) - Auth fast-path: short-circuit Neon Auth DNS calls when not configured - PERF_TEST_AUTH=1 flag enables prod-mode admin auth benchmarking - Stale build artifacts fix (clean rebuild restores fast behavior) Measured (production build, sequential requests, dev_session cookie): - 102/103 pages: TTFB ≤ 10ms - 1 page: TTFB 11-20ms - 0 pages exceed 50ms TTFB - First Paint (browser): 28-84ms on admin pages
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
/**
|
||||
* Track the previous value of a prop. Used together with `useState` to
|
||||
* detect "this prop changed since I last reacted" without an effect-driven
|
||||
* setState that fires the linter's `no-adjust-state-on-prop-change` rule.
|
||||
*
|
||||
* Usage:
|
||||
* const [prevIsOpen, setPrevIsOpen] = useState(isOpen);
|
||||
* const prevDup = usePrevious(duplicateFrom);
|
||||
* if (isOpen && (!prevIsOpen || prevDup !== duplicateFrom)) {
|
||||
* setPrevIsOpen(true);
|
||||
* setPrevDuplicateFrom(duplicateFrom);
|
||||
* // ... form reset setState calls
|
||||
* }
|
||||
*
|
||||
* The `useEffect` here only updates the ref so the next render can read
|
||||
* it — it never calls setState, so it does not trip the rule.
|
||||
*/
|
||||
export function usePrevious<T>(value: T): T | undefined {
|
||||
const ref = useRef<T | undefined>(undefined);
|
||||
useEffect(() => {
|
||||
ref.current = value;
|
||||
});
|
||||
return ref.current;
|
||||
}
|
||||
Reference in New Issue
Block a user