Group
  • Performance

    Replace wasteful API polling loops

    Finds setInterval polling that hammers the API and replaces it with backoff, visibility-aware polling, or push alternatives.

    • Debug & fix
    • Improve quality
    • Intermediate
    • General

Free Prompt

Find every polling loop in my app and make it cheaper. 1. Inventory: locate every setInterval or recursive setTimeout that calls my API: dashboards refreshing, notification badges, job status checks, chat or feed updates, 'is it done yet' loops. For each, note the interval and what it fetches. 2. Visibility-aware: every poller must pause when the tab is hidden (document.visibilityState) and resume on return. A user with ten background tabs should not be running ten pollers against my server all night. 3. Backoff: pollers waiting for a condition (job completion, payment confirmation) should use exponential backoff with a cap and a stop condition, not a fixed 2-second hammer forever. Stop polling when the condition resolves or the user navigates away; audit for interval leaks where navigating between pages stacks multiple live intervals. 4. Deduplicate: if multiple components poll the same endpoint, centralize into one shared poller or cache so five components do not mean five requests per interval. 5. Push where it earns it: for data that needs to feel live (notifications, chat, collaborative views), evaluate replacing polling with Server-Sent Events or websockets. Recommend per case; do not convert everything. If my platform makes long-lived connections painful (serverless), prefer smarter polling over a fragile socket setup. 6. Server-side relief: for endpoints that must keep being polled, add ETag/conditional-request support so unchanged data returns a cheap 304. Do not change how fresh the data feels to users; if a dashboard updates every 5 seconds today it should still feel live. Do not introduce a websocket layer for a single low-traffic badge counter. Give me: the poller inventory with interval and purpose, what changed per poller (pause-on-hidden, backoff, dedupe, push), and the estimated request volume reduction per day.

What This Does / How This Helps

Finds every polling loop in your frontend and stops the ones that are quietly DDoSing your own API. The classic vibe-coded pattern is setInterval(fetch, 2000) with no pause when the tab hides, no cleanup when the user navigates, and the same endpoint polled by three components at once. Ten open tabs per user multiplies it further. Your server spend and response times carry the cost of requests nobody is looking at. The prompt inventories every poller, makes them pause in hidden tabs, adds backoff to condition-waiting loops, kills interval leaks, and upgrades the genuinely-live features to push where it pays off.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts