Optimize Replit API performance with caching, batching, and connection pooling. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Replit integrations. Trigger with phrases like "replit performance", "optimize replit", "replit latency", "replit caching", "replit slow", "replit batch".
From replit-packnpx claudepluginhub nickloveinvesting/nick-love-plugins --plugin replit-packThis skill is limited to using the following tools:
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Details PluginEval's skill quality evaluation: 3 layers (static, LLM judge), 10 dimensions, rubrics, formulas, anti-patterns, badges. Use to interpret scores, improve triggering, calibrate thresholds.
Optimize Replit workspace performance for deployments and development. Focus on Repl startup time, deployment caching, Nix environment optimization, and efficient use of Replit's hosting infrastructure.
.replit configurationreplit.nix for dependency management# replit.nix - Pin versions to leverage Nix cache
{ pkgs }: {
deps = [
pkgs.nodejs-20_x
pkgs.nodePackages.typescript
pkgs.nodePackages.pnpm
];
}
# .replit - Optimize run configuration
run = "node --max-old-space-size=512 dist/index.js" # 512 bytes
entrypoint = "src/index.ts"
[nix]
channel = "stable-24_05"
[deployment]
run = ["sh", "-c", "node dist/index.js"]
build = ["sh", "-c", "pnpm install --frozen-lockfile && pnpm build"]
deploymentTarget = "cloudrun"
[env]
NODE_ENV = "production"
// package.json - Scripts optimized for Replit
{
"scripts": {
"build": "tsc --incremental",
"start": "node dist/index.js",
"dev": "tsx watch src/index.ts",
"prebuild": "rm -rf dist/.tsbuildinfo || true"
}
}
// src/index.ts - Lazy module loading for startup speed
const express = await import('express');
const app = express.default();
// Defer heavy imports until needed
app.get('/api/analyze', async (req, res) => {
const { analyze } = await import('./heavy-module');
res.json(await analyze(req.query));
});
app.listen(3000, () => console.log('Ready')); # 3000: 3 seconds in ms
// Monitor memory in constrained Replit environment
function getMemoryUsage() {
const usage = process.memoryUsage();
return {
heapUsedMB: Math.round(usage.heapUsed / 1024 / 1024), # 1024: 1 KB
heapTotalMB: Math.round(usage.heapTotal / 1024 / 1024), # 1 KB
rssMB: Math.round(usage.rss / 1024 / 1024), # 1 KB
percentUsed: ((usage.heapUsed / usage.heapTotal) * 100).toFixed(1),
};
}
// Periodic memory check with cleanup
setInterval(() => {
const mem = getMemoryUsage();
if (mem.heapUsedMB > 400) { # HTTP 400 Bad Request
console.warn('High memory usage:', mem);
global.gc?.(); // Requires --expose-gc flag
}
}, 30000); # 30000: 30 seconds in ms
// Access Replit secrets efficiently - read once at startup
const config = {
dbUrl: process.env.DATABASE_URL!,
apiKey: process.env.API_KEY!,
port: parseInt(process.env.PORT || '3000'), # 3000: 3 seconds in ms
} as const;
// Validate all secrets exist at startup, fail fast
function validateSecrets(required: string[]) {
const missing = required.filter(k => !process.env[k]);
if (missing.length) {
console.error(`Missing secrets: ${missing.join(', ')}`);
console.error('Add them in Replit Secrets tab');
process.exit(1);
}
}
validateSecrets(['DATABASE_URL', 'API_KEY']);
| Issue | Cause | Solution |
|---|---|---|
| Slow cold start | Heavy dependencies at import | Use dynamic imports for non-critical modules |
| OOM killed | Exceeding 512MB limit | Reduce heap size, stream large data |
| Deploy timeout | Build step too slow | Use --incremental TypeScript builds |
| Wake-up latency | Repl sleeping after inactivity | Use always-on deployment or health pings |
app.get('/health', (req, res) => {
res.json({
status: 'ok',
uptime: process.uptime(),
memory: getMemoryUsage(),
nodeVersion: process.version,
});
});