· · Matthew Ford  · 5 min read

10 tips to reduce latency in web applications

10 tips to reduce latency in web applications
A slow web application costs you twice: people leave before they have seen what you offer, and the ones who stay enjoy the experience less. The good news is that most latency comes from a short list of causes, and you can find them before spending money on fixes. One caution before the tips: you will find plenty of articles quoting precise universal figures for what a second of delay costs. Real impact varies by site and audience, so measure your own. Which brings us neatly to the first tip. ## 1. Measure before you optimise Guessing is the most expensive performance strategy. Use real-user monitoring (your analytics or a RUM tool) alongside lab tests like Lighthouse and WebPageTest, and check Core Web Vitals in Search Console. Look at server response time separately from front-end loading: the fix for a slow database is very different from the fix for a heavy homepage. ## 2. Fix the database first In our support work, the database is the most common culprit. N+1 queries (one query per item in a list, instead of one query for the lot), missing indexes and unbounded result sets all add server time on every request. Your APM tool or slow-query log will show which endpoints to start with. ## 3. Cache the things that do not change Page fragments, rendered templates, API responses, session data: much of what your application builds on each request is identical to the previous one. Rails gives you fragment and low-level caching out of the box, and current versions make it easy to back caches with your existing database infrastructure rather than extra services. Cache invalidation needs thought, so start with the read-heavy, rarely-changing content. ## 4. Move slow work out of the request Sending emails, processing uploads, calling third-party APIs, generating reports: none of these should happen while a user waits for a page. Push them into background jobs and show the user an immediate response, with a notification or refresh when the work finishes. ## 5. Put static assets on a CDN Images, JavaScript, CSS, fonts and downloads should be served from a content delivery network close to your users, not from your application server. This reduces both network distance and load on the app, and it is usually one of the cheapest wins available. ## 6. Send smaller images Oversized images are still the heaviest thing on most pages. Resize to the dimensions actually displayed, use modern formats (WebP/AVIF) with sensible compression, lazy-load images below the fold, and do not forget to set width and height so the page does not jump around while loading. ## 7. Be ruthless with third-party scripts Analytics, chat widgets, advertising pixels, A/B testing tools, font services: each one adds DNS lookups, connections and JavaScript execution, often on someone else's infrastructure with no performance budget. Audit what loads on your pages, remove what you no longer use, and load the rest asynchronously or after consent. ## 8. Trim and defer your own JavaScript Large bundles delay the point where a page becomes usable. Remove unused dependencies, split code so pages only load what they need, and defer anything that is not required for the first render. If you are rebuilding an interface, modern Rails tools like Turbo and Stimulus can deliver a responsive feel with far less JavaScript than a full single-page application. ## 9. Use modern protocols and compression Serve over HTTP/2 or HTTP/3 so browsers can multiplex requests, and turn on Brotli or gzip compression for text assets. Check keep-alive and TLS settings while you are there. These are hosting-level changes with site-wide benefits. ## 10. Keep score after launch Performance regresses quietly as features, scripts and content accumulate. Set a performance budget (page weight, response time, Core Web Vitals thresholds), monitor it, and alert when key pages drift. An hour of review a month beats a painful rescue project every couple of years. ## What this looks like in practice Working with Easol, the experiences platform, our performance work [cut some page load times by 50%](/client-stories/easol/). That came from the same unglamorous process: measure, find the real bottlenecks, fix them in order of impact. If your application is slow and you are not sure where to start, our [Rails support and maintenance team](/services/ruby-on-rails-support-maintenance/) investigates performance as part of ongoing support, and a one-off assessment is often enough to identify the big wins. [Tell us what is slow](/contact/) and we will take a look.

Discuss your software, technical leadership or AI plans

Tell us what you need to build, improve or decide.

We can help with software development and ongoing support, fractional CTO leadership, and practical AI adoption. Speak to our senior team about your priorities, our approach and availability.

Book a free intro call

Choose 15 or 30 minutes. Booking requests require confirmation by email.

Back to Blog

Related Posts