Compliance Gotcha With Hotwire

Engineering Insights

Steve Zelaznik
#
Min Read
Published On
August 28, 2025
Updated On
February 5, 2026
Compliance Gotcha With Hotwire

Here at the Gnar, we have a few major clients in the criminal background check business. As software engineers, this is a huge responsibility. We have to protect the public while at the same time respecting the privacy as much as possible of people who have trusted us with their data.

In fields like this, there’s a “minimum need to know” principle. Users of any website should only view the minimum necessary amount of other people’s personal data in order to do their jobs. A similar field where this applies is medical software, which I’ll use as the example for the remainder of this post. A user of medical software should not be allowed to view medical records of somebody they’re not treating, at least not without the patient’s prior consent.

This is one of the reasons why an audit trail is so important. Any time a user visits a patient’s page, there needs to be a record of it. If the user didn’t have a good reason to view that data, the user can face serious consequences.

Enter Hotwire Prefetching

Hotwire, which comes standard in new Rails apps 7 or above, comes with sensible defaults to improve perceived performance. In order to improve page load time, when a user hovers over a link, Hotwire makes an AJAX request in the background, fetching the contents of the link before the user has even clicked. Most users will have no idea that this is happening.  They just notice that the page seems to load instantaneously, which, before Hotwire, would never happen.

Here’s the problem: the Rails logs can’t tell the difference between whether a user clicked on the page or merely hovered their mouse cursor over the link.

It can make it look like users were viewing patient data that they had no authorization to do so.  Let’s say they hovered over the link to the medical data for “John Smith #1”, but their actual patient was “John Smith #2”.  The browser prefetches both patients as the user’s browser hovers over each link.

Also, from a compliance perspective, IT DOESN’T MATTER whether the user clicked.  As soon as a patient’s data is on an unauthorized user’s computer, a violation of privacy has taken place.

How To Disable Prefetching

If we want to disable prefetching on an individual link, we simply set a data attribute turbo-prefetch to false.

<a href="/patients/31415" data-turbo-prefetch="false">View Patient 31415</a>

If we want to enable prefetching, we set it to true.

<a href="/patients/31415" data-turbo-prefetch="true">View Patient 31415</a>

Setting this data attribute applies not only to this element but to ALL CHILD ELEMENTS. So if privacy and compliance are concerns as they are with healthcare and criminal background applications, we should set this attribute to “false” on the body, but we can still opt-in to pre-fetching for pages we know are safe:

<body data-turbo-prefetch="false">
  <!-- We can opt into pre-fetching for pages with no personal info -->
  <a href="/outstanding_tasks_for_user" data-turbo-prefetch="true">
    Outstanding Tasks For User
  </a>

  <!-- No Prefetching For the Patient Link -->
  <a href="/patients/31415">
    View Patient 31415
  </a>
</body>

This creates an opt-in system where we only prefetch when it’s done deliberately.

If we want to play it even safer, we can just set prefetch to false for the entire document.

<meta content="false" name="turbo-prefetch">

Final Thoughts

This is yet another example where the bells and whistles of modern JavaScript can make for a slick experience in an app, but we still have to make sure we understand the fundamentals of what our app is actually doing first.

Author headshot
Written by
Steve Zelaznik
Software Engineer
, The Gnar Company

Steve Zelaznik is a Senior Software Engineer at The Gnar Company, where he leads complex software initiatives for government and enterprise clients. His recent work includes building mission-critical systems for the Commonwealth of Massachusetts Department of Transportation and developing accessible digital tools that have helped seniors secure over $10 million in property tax relief through AARP Foundation's Property Tax-Aide program. Steve specializes in creating scalable, user-centered applications that translate policy requirements into intuitive technology solutions.

Related Insights

See All Articles
Engineering Insights
Top React Native App Development Companies In 2026

Top React Native App Development Companies In 2026

Compare the top React Native app development companies of 2026. Discover how to vet senior engineers, avoid technical debt, and why our 12-month bug-free warranty sets the standard for high-performance mobile builds.
Engineering Insights
Context-Driven Development: The AI-First Alternative to Agile

Context-Driven Development: The AI-First Alternative to Agile

Context-Driven Development (CDD) is a software development methodology designed for AI-assisted coding. Learn how CDD differs from Agile and why detailed requirements are now the source code of the future.
Product Insights
How to Choose the Right Software Development Partner in 2026

How to Choose the Right Software Development Partner in 2026

Avoid project failure and costly delays. Learn how to choose the right software development partner in 2026 with our guide to vetting quality, teams, and warranties.
Previous
Next
See All Articles