Nowy standard. Twoje centrum tworzenia inteligentnego, szybkiego i zrównoważonego oprogramowania AI
Spis treści
i jeszcze 9
To improve web performance with Rails, start by measuring real visits against Core Web Vitals. Then cache at the view, database and HTTP layers, and let the Rails 8 default stack take over the delivery work that used to need hand tuning.
Stefan Wintermeyer's talk WebPerformance with Rails 5.2 at Wroclove.rb 2018 in Wrocław, which our team attended, collects many of these techniques in a dense list of low-hanging fruit that many developers skip. Most of the list still holds eight years later, two items no longer work in current browsers, and Rails 8 handles part of the rest by default.
Our Ruby on Rails development team has delivered over 100 Rails projects. One of them was a Rails and Vue.js rebuild of Merck's DORA app, optimized for slow internet connections.
Executive Summary
Rails apps get faster in 2026 by measuring real visits against Core Web Vitals, caching views, counts and HTTP responses, and relying on Rails 8 defaults for HTTP/2 and asset compression.
Speed also affects revenue: in an A/B test, Vodafone found a 31% improvement in LCP led to 8% more sales. Two browser-level techniques are dead ends: Chrome and Firefox abandoned HTTP/2 Server Push, and the prerender hint is deprecated.
Why Does Slow Rails Response Time Cost Money?
Server response time sits at the start of every page load. Time to First Byte is the first of four subparts Google's web.dev team uses to break down Largest Contentful Paint, and "A high TTFB can make achieving a 2.5 second LCP challenging, or even impossible," according to its guide to optimizing LCP. Slow Rails responses therefore cap LCP, the metric Vodafone tied to sales.
Outdated techniques waste effort as well: a team can configure Server Push that Chrome and Firefox ignore. The table rates common Rails performance techniques against Rails 8.1 (8.1.4.1 as of November 2026) and current browser documentation.
Technique | Status in 2026 | What to do now |
|---|---|---|
Fragment and counter caching | Current; Solid Cache is the default store for new apps (Rails caching guide) | Keep |
ETag and Last-Modified via | Current; Rails generates weak ETags by default | Keep |
Page caching with | Removed from core in Rails 4.0; now the actionpack-page_caching gem | Use for rarely changing public pages |
Nginx in front of Rails | Rails 8 puts Thruster in front of Puma (Rails 8 release post) | Drop unless you need it |
HTTP/2 Server Push | Off by default since Chrome 106 (Chrome announcement) and since Firefox 132 (MDN Firefox 132 notes) | Send 103 Early Hints or preload |
Brotli with gzip fallback | Current; cut text resources ~25–30% below served gzip in a 2018 HTTP Archive data analysis | Keep, via CDN or proxy |
Serving assets without a CDN over HTTP/2 | Distance to the server raises TTFB | Keep a CDN |
How Do You Measure Rails Web Performance in 2026?
PageSpeed Insights and WebPageTest are the two tools we reach for first. PageSpeed Insights combines lab data from Lighthouse with field data from the Chrome User Experience Report. The PSI documentation rates Core Web Vitals as good at LCP within 2,500 ms, INP within 200 ms and CLS within 0.1, measured at the 75th percentile of real visits, while a lab score of 90 or above counts as good.
The measurement changes how a team works: every caching or delivery change gets checked against field data before and after it ships, so the effect on LCP shows up in the numbers. Google stops short of promising a ranking boost for the result. Its Search guidance says achieving good Core Web Vitals "aligns with what our core ranking systems seek to reward."
WebPageTest answers a different question: how a page loads from a chosen location, device and browser, with filmstrip and video capture showing what the visitor sees. We have relied on it across many projects. The tool now belongs to LogicMonitor, which acquired its previous owner, Catchpoint. Self-hosting a private instance is documented, but the master branch of the WebPageTest repository is licensed under Polyform Shield 1.0.0, with Apache 2.0 kept on a separate branch, so check the license first.
Which Rails Caching Techniques Cut Server Response Time?
Fragment caching is the first lever. Rails wraps a piece of view logic in a cache block whose key includes a template digest and whose version comes from the record, so once a product is touched, old fragments are ignored and rebuilt on the next request. Wintermeyer's demo nested single-row caches inside a whole-table cache, a pattern the Rails guide calls Russian doll caching. The guide pairs it with touch: true on belongs_to, so a change to a review also expires the product fragment around it.
Where the cache lives changed in Rails 8: Solid Cache keeps entries in the database on disk, and the Rails 8 release post says this "allows for a vastly larger and cheaper cache thanks to its use of disk storage rather than RAM storage." For a content-heavy app, a larger cache means more fragments survive between requests.
Rendering a count of associated records on every row adds a COUNT query per row. A counter_cache column stores the total on the parent record "to avoid running an SQL query to calculate the number of posts," in the words of the Active Record counter cache docs, and reset_counters repairs the value if direct SQL writes push it out of sync.
Query-level work such as N+1 detection and indexing sits in our Rails database optimization guide. Low-level caching patterns are covered in our guide to Rails caching strategies.
How Do HTTP Caching and Page Caching Save Server Work?
Conditional GET lets the browser skip downloading what it already holds. In a controller, fresh_when binds the ETag and Last-Modified headers to the state of a record, and when the browser's copy is still fresh, Rails answers 304 Not Modified with no body.
For a GET /products/:id response that should change only when the product's updated_at changes, fresh_when is the tool. Rails generates weak ETags by default, which let semantically equivalent responses share an ETag, while a strong ETag requires the body to match exactly.
Page caching goes further by writing the whole response to the public directory, so later requests are answered with a static file. The caches_page API left Rails core in version 4.0 and lives on as a gem, which still suits pages that rarely change, such as a public landing page.
Dynamic, user-specific pages are harder. In his talk, Wintermeyer said caching them is possible but takes much more effort. One option is letting the client cache the endpoint and setting a Vary header, which tells caches to store responses separately "based on the headers listed in the Vary field." Each stored variant takes disk space, a cost that grows with the number of users you serve.
How Should a Rails App Serve Images on Slow Connections?
Wintermeyer's goal was the right image size and format for each browser and device, and Active Storage is the Rails-native way to get there.
Calling variant(resize_to_limit: [100, 100]) produces a resized copy, and marking a named variant preprocessed: true makes Rails enqueue a job to generate it after the file is attached. In proxy mode, the Active Storage guide notes that "the CDN will cache the attachment without any extra configuration." Detecting the browser or device needs tooling outside Active Storage.
Payload size matters most where networks are weakest. When we rebuilt Merck's DORA app with Rails and Vue.js, over 90% of visitors used mobile devices and 60% used Opera Mini. The team built a dedicated Opera Mini version, brought the app down to 0.7 MB and now runs it in Swahili, Amharic and other languages across nine African countries.
Does HTTP/2 Still Speed Up Rails Apps Without Server Push?
Wintermeyer's slide was blunt: "HTTP/2 provides an average WebPerformance improvement of 20%." He gave no source for the figure, and the gain depends on how a site is built. Cloudflare CEO Matthew Prince described the HTTP/1.1 playbook as one where "you don’t use encryption, you shard domains, you never embed anything on pages." Under HTTP/2, he said, "sharding is the worst possible thing you can do," as quoted by The New Stack.
The protocol does not require TLS, but the HTTP/2 FAQ notes that "currently no browser supports HTTP/2 unencrypted." On Rails 8, Thruster provides HTTP/2 along with automatic TLS certificates from Let's Encrypt.
Server Push, one of the reasons the talk gave for dropping CDNs, is gone. Chrome found only 1.25% of HTTP/2 sites used it, and that analysis showed "in many cases performance regressions." Chrome 106 deactivated it by default, and Firefox 132 did the same in October 2024, setting network.http.http2.allow-push to false and noting the implementation may be removed entirely later.
Early Hints took its place. A server sends Link headers for preload or preconnect "while it is still preparing a response," per MDN's reference for status 103, and most browsers honor them only over HTTP/2 or later. Rails exposes this through request.send_early_hints, which works when the app server provides rack.early_hints.
Does a Rails 8 App Still Need a CDN and Brotli?
Wintermeyer argued that "In many cases where a CDN made sense with HTTP/1.1 it doesn't make sense any more," and suggested serving assets straight from the Rails server.
We disagree. Multiplexing lets one connection carry many requests, but it cannot shorten the distance between server and visitor, and web.dev lists "visitors located far away from the nearest site server" among the causes of a high TTFB, so we would not strip a CDN out of a Rails stack lightly.
Compression is the cheaper win. Brotli is its own format, built on LZ77 and Huffman coding, and in a 2018 analysis of HTTP Archive data, Brotli cut text resources by roughly 25–30% against the gzip versions sites were serving, including 32% on one jQuery UI build and 27% on the largest script of a top-1000 site.
Browser support for Brotli is near-universal, and Wintermeyer's fallback advice holds: "Always offer both." Thruster's README documents gzip compression only, so on a default Rails 8 stack Brotli needs a CDN or a proxy configured for it, with gzip kept as the fallback for clients that do not accept Brotli.
Heroku or Your Own Servers: Which Gives More Control Over Rails Performance?
Wintermeyer's slide on hosting is direct: "Heroku is good for a quick start but has never been a good choice for good WebPerformance."
A PaaS gets a basic app running in minutes, and the price is less control over machines and configuration, which is where server-level tuning happens. If performance is the top priority, we recommend a dedicated server configured for the application's specific needs.
Rails 8 made that side of the trade easier to reach. According to the release announcement, the framework "comes preconfigured with Kamal 2 for deploying your application anywhere," whether the target is a cloud VM or your own hardware. With Thruster sitting in front of Puma, the Rails team says "there’s no need to put an Nginx or any other web server in front," which removes one layer a self-hosted setup used to need.
A managed platform still makes sense for a team with no one to run servers. The decision comes down to whether the team can own patching, capacity and monitoring in exchange for the configuration control that performance tuning needs.
Which Resource Hints Still Work in 2026?
Resource hints tell the browser about work it can start early. dns-prefetch, preconnect and prefetch work within limits, while prerender has a replacement that is not yet supported everywhere. Statuses come from MDN, chiefly its guide to speculative loading.
Hint | What it does | Status in 2026 |
|---|---|---|
| Resolves DNS for another origin ahead of time | Widely supported; no benefit for same-origin requests |
| Opens the DNS, TCP and TLS handshake to another origin early | Widely supported; no benefit for same-origin requests |
| Fetches a resource for a likely next navigation | Cache partitioning limits it for cross-site use |
| Hints that the browser should render a target page in the background | Deprecated and non-standard; MDN describes it as Chrome-specific and superseded by Speculation Rules |
Speculation Rules | Prefetches or prerenders future documents from JSON rules |
Rails apps on Turbo 8 get link prefetching without extra markup. According to the Turbo handbook, prefetching links on hover is enabled by default since Turbo v8, and data-turbo-prefetch="false" switches it off for an element and its children.
Which Habits Keep Rails Performance From Regressing?
Set a time budget for what the page loads, and cancel features that are not needed once the budget runs out, for example by aborting trailing XHR requests. For the numbers, use Core Web Vitals: RAIL's own page calls them "the recommended approach for defining performance goals over RAIL," so the thresholds from your measurement step double as the budget.
Turn caching on in development. Action Controller caching runs only in production by default, and bin/rails dev:cache toggles it locally. Wintermeyer recommended turning it on to catch obvious caching bugs before they reach production.
In our experience with Rails projects, cache-related bugs are hard to identify, hard to describe and almost impossible to reproduce, so a bug found on a laptop costs far less than one found by users.
For the networking fundamentals under all of this, Wintermeyer recommended Ilya Grigorik's High Performance Browser Networking, and so do we. The full text is available online under a Creative Commons license.
What Slows Down a Rails Performance Overhaul?
Cache invalidation is the first source of friction. Every fragment needs a key that changes when its data changes, and touch: true adds a write to the parent record on every child update. Teams that skip development caching meet these bugs in production instead.
Personalized pages limit how much caching applies. Page caching and CDN caching work on responses that are identical for every visitor, so per-user responses either need a Vary strategy, with the storage cost each variant brings, or stay uncached and rely on fragment caching inside the request.
Browser support splits the newer techniques. Speculation Rules work only in some browsers, Early Hints mostly require HTTP/2 or later, and prefetch loses value across sites under cache partitioning. Each needs a fallback that leaves the page correct when the hint is ignored.
Infrastructure ownership changes with the hosting model. Moving from a PaaS to Kamal-managed servers puts patching, capacity and monitoring on the team. Thruster automates TLS certificates, but Brotli still needs a CDN or a proxy, and a CDN brings its own caching rules for personalized responses.
Key Takeaways
Vodafone's A/B test linked a 31% LCP improvement to 8% more sales, and Time to First Byte is the first subpart of LCP.
Judge Rails pages at the 75th percentile: LCP within 2.5 seconds, INP within 200 ms and CLS within 0.1.
Fragment, Russian doll and counter caching cut server work. Solid Cache makes a disk-backed store the default for new apps.
Chrome 106 and Firefox 132 both turned HTTP/2 Server Push off by default; use Early Hints, and replace prerender with Speculation Rules where supported.
Keep a CDN for distant visitors and offer Brotli (roughly 25–30% smaller than gzip on text) with a gzip fallback.
What Makes Rails Performance Work Last?
Techniques that live in Rails defaults or web standards outlast browser-specific tricks: fragment caching, counter caches and conditional GET are documented for current Rails, while Server Push and prerender both lost their browser support. Keeping an app fast means treating performance as a measured property of the product, re-checking it against field data when browsers ship changes, and naming who owns each layer, from fragment keys to CDN rules.
If you need to find which of these layers is slowing your Rails app down, talk to our team.
Rails Web Performance FAQ





