Improve platform speed and search responsiveness
Implement performance optimizations including HTTP compression, enhanced caching strategies, reduced search debounce time, and optimized thumbnail generation. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/UCWygK2
This commit is contained in:
@@ -26,11 +26,14 @@ export default function SearchHeader({
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Debounced search function - waits 500ms after user stops typing
|
||||
// Optimized debounced search - waits 300ms and filters short queries
|
||||
const debouncedSearch = useCallback(
|
||||
debounce((query: string) => {
|
||||
onSearch(query);
|
||||
}, 500),
|
||||
// Only search if query is meaningful (2+ characters or empty for reset)
|
||||
if (query.length === 0 || query.length >= 2) {
|
||||
onSearch(query);
|
||||
}
|
||||
}, 300),
|
||||
[onSearch, debounce]
|
||||
);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function Home() {
|
||||
|
||||
|
||||
|
||||
// Fetch videos
|
||||
// Fetch videos with optimized caching
|
||||
const { data: videosResponse, isLoading, refetch } = useQuery<VideosResponse>({
|
||||
queryKey: ["/api/videos", {
|
||||
limit: 20,
|
||||
@@ -41,7 +41,11 @@ export default function Home() {
|
||||
throw new Error('Failed to fetch videos');
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
gcTime: 10 * 60 * 1000, // 10 minutes
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false
|
||||
});
|
||||
|
||||
// Update videos when new data comes in
|
||||
|
||||
Reference in New Issue
Block a user